Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • masterpiece
    replied
    About the tview, from the way you run the command, I think u missed something. Have you sort the bam file using samtool sort command? If not, you have to sort them 1st, before doing indexing.

    Code:
    samtools sort [-on] [-m <maxMem>] <in.bam> <out.prefix>

    Code:
    samtools index <sorted.bam>

    And from the tview run, u forgot to include the reference sequence

    Code:
    samtools tview  <aln.sorted.bam> [ref.fasta]


    You can check out this post. This might help you

    Discussion of next-gen sequencing related bioinformatics: resources, algorithms, open source efforts, etc
    Last edited by masterpiece; 09-27-2012, 07:38 PM.

    Leave a comment:


  • shuoguo
    replied
    Originally posted by dpryan View Post
    Ah, then since this is just hg18, you have a two options:

    1) Do what I suggested above, substituting the length of the various chromosomes in hg18 for the made up values I originally suggested. You would have to look up these values.

    2) Download the hg18 fasta file and run "samtools faidx" on it. You can then use the "-t" option that you tried before with the resulting .fai file. This is effectively the same as option 1, but requires less googling.

    BTW, I hope you replaced all of the coordinate information rather than just the chromosome (position 3). Otherwise whatever you do downstream will be messed up.
    Thank you!
    I did something similar and it is able to produce bam files now.

    Although kind of disappointed that i cannot use the tview option

    /usr/local/samtools-0.1.18/samtools tview test.bam
    [bam_index_load] fail to load BAM index.
    $ /usr/local/samtools-0.1.18/samtools index test.bam
    [bam_index_core] the alignment is not sorted (all-hg18_9815): 2498970
    > 2498636 in 1-th chr
    [bam_index_build2] fail to index the BAM file.

    Leave a comment:


  • dpryan
    replied
    Ah, then since this is just hg18, you have a two options:

    1) Do what I suggested above, substituting the length of the various chromosomes in hg18 for the made up values I originally suggested. You would have to look up these values.

    2) Download the hg18 fasta file and run "samtools faidx" on it. You can then use the "-t" option that you tried before with the resulting .fai file. This is effectively the same as option 1, but requires less googling.

    BTW, I hope you replaced all of the coordinate information rather than just the chromosome (position 3). Otherwise whatever you do downstream will be messed up.

    Leave a comment:


  • shuoguo
    replied
    Originally posted by masterpiece View Post
    As what dpryan and other said, its the header issue. May I know how you generate the sam file at the first place?
    Step 1: i have the original bam and bam.bai files downloaded from web. These are aligned with hg18.

    Step 2: i transfer the same bam file to a bed file and a sam file.

    Step 3: i liftover the bed file with the hg19 chain file (so the position is updated)

    Step 4: I replace the position (3rd column) in the sam file with the liftover file.

    Step 5: I want to transfer this sam file back to bam file, getting the error

    Thanks for the help!!

    Leave a comment:


  • masterpiece
    replied
    As what dpryan and other said, its the header issue. May I know how you generate the sam file at the first place?

    Leave a comment:


  • dpryan
    replied
    Without knowing the chromosome names and sizes, you won't be able to make a BAM file (there'd be no way for it to know how to create the header). You can probably half-ass it by just getting a sorted list of chromosomes from your SAM file:
    Code:
    cat all-hg18-lifted.sam | cut -f 3 | sort | uniq > ref.fa.fai
    For each line in ref.fa.fai, you then need to add that chromosome's length (separated by a tab from the chromosome name, so "chr1 500000000"). Obviously you don't know that, but you could just use a sufficiently large number. That would at least allow things to be converted to a BAM file. I don't know if that would screw things up with any downstream applications, but I can't currently think of a situation where it would.

    Leave a comment:


  • shuoguo
    replied
    samtools-0.1.18

    Leave a comment:


  • maubp
    replied
    Which version of samtools do you have?

    Leave a comment:


  • shuoguo
    replied
    tried that with no luck. thanks for the reply.

    Originally posted by swbarnes2 View Post
    Use the caret to write to the .bam

    Leave a comment:


  • swbarnes2
    replied
    Originally posted by shuoguo View Post
    It seems that no matter how I run it it will just spit out errors
    Use the caret to write to the .bam

    /usr/local/samtools-0.1.18/samtools view -bS all-hg18-lifted.sam > test.bam

    Leave a comment:


  • shuoguo
    replied
    in my case i do not have teh original fasta files

    Originally posted by maubp View Post
    That was shorthand for your reference genome in FASTA format.

    Leave a comment:


  • shuoguo
    replied
    It seems that no matter how I run it it will just spit out errors

    $ /usr/local/samtools-0.1.18/samtools view -bS all-hg18-lifted.sam -o test.bam
    [samopen] no @SQ lines in the header.
    [sam_read1] missing header? Abort!

    ]$ /usr/local/samtools-0.1.18/samtools view -bS all-hg18-lifted.sam test.bam
    [samopen] no @SQ lines in the header.
    [main_samview] random alignment retrieval only works for indexed BAM files.

    Leave a comment:


  • swbarnes2
    replied
    Try

    samtools view -bSh mysam.sam > mybam.bam
    I don't think you need the -t, and I'm not sure that the software likes you putting the -o option after the input file name.

    -h will make sure the header goes on there.

    Leave a comment:


  • maubp
    replied
    That was shorthand for your reference genome in FASTA format.

    Leave a comment:


  • shuoguo
    replied
    find online manual said:
    If your SAM file has header @SQ lines, you may get BAM by ...
    If not, you need to have your reference file ref.fa and then do this:
    looks like i need a ref.fa file, not sure what is that? how does it looks like and how to get it?

    thanks

    Shuoguo

    Leave a comment:

Latest Articles

Collapse

  • seqadmin
    Genetic Variation in Immunogenetics and Antibody Diversity
    by seqadmin



    The field of immunogenetics explores how genetic variations influence immune responses and susceptibility to disease. In a recent SEQanswers webinar, Oscar Rodriguez, Ph.D., Postdoctoral Researcher at the University of Louisville, and Ruben Martínez Barricarte, Ph.D., Assistant Professor of Medicine at Vanderbilt University, shared recent advancements in immunogenetics. This article discusses their research on genetic variation in antibody loci, antibody production processes,...
    11-06-2024, 07:24 PM
  • seqadmin
    Choosing Between NGS and qPCR
    by seqadmin



    Next-generation sequencing (NGS) and quantitative polymerase chain reaction (qPCR) are essential techniques for investigating the genome, transcriptome, and epigenome. In many cases, choosing the appropriate technique is straightforward, but in others, it can be more challenging to determine the most effective option. A simple distinction is that smaller, more focused projects are typically better suited for qPCR, while larger, more complex datasets benefit from NGS. However,...
    10-18-2024, 07:11 AM

ad_right_rmr

Collapse

News

Collapse

Topics Statistics Last Post
Started by seqadmin, Today, 06:13 AM
0 responses
9 views
0 likes
Last Post seqadmin  
Started by seqadmin, 11-01-2024, 06:09 AM
0 responses
30 views
0 likes
Last Post seqadmin  
Started by seqadmin, 10-30-2024, 05:31 AM
0 responses
21 views
0 likes
Last Post seqadmin  
Started by seqadmin, 10-24-2024, 06:58 AM
0 responses
26 views
0 likes
Last Post seqadmin  
Working...
X