Skip to main content

Questions tagged [samtools]

Questions specific to interacting with and post-processing sequence alignments using the SAMtools package. For questions specifically about formats SAM, BAM or CRAM use tags sam or bam,

Filter by
Sorted by
Tagged with
1 vote
1 answer
61 views

How to subset BAM file based on read length range (120-180) bp?

Hi I'm wondering how I can subset a BAM file based on read length. Precisely I want just read lengths of 120 to 180 bp reads in the new BAM file. I'm trying several way, but none of them giving the ...
1 vote
1 answer
28 views

Problem while mapping reads to mtDNA (SortSam)

I am trying to map MiSeq reads to a reference genome and extract mutations using MToolBox, which implements gsnap, GATK, Picard, and other tools. When running the tool with example data, there were no ...
3 votes
1 answer
117 views

How to reduce BAM

Consider a sorted, indexed, only mapped reads containing BAM file. Is there a way to get a sub BAM based on read line numbers? This can be done iteratively using a counter but its too slow. Is there a ...
8 votes
2 answers
3k views

Convert BAM to properly paired FASTQ files

I thought I had figured this one out. But apparently not. I need to convert a BAM file of paired-end alignments to two FASTQ files of paired reads to realign them, with a twist: I only want reads that ...
3 votes
1 answer
40 views

Different line length in sequence 'chrY'

I just downloaded a reference genome (using wget), and attempted to use it with samtools view. However, I received the following error: ...
1 vote
1 answer
39 views

Pysam - fetch reads within region

I'm using pysam (and also samtools) to find all reads in BAM files that are within a specific region py_bamfile.fetch('4',42266768,42268410) and the following read ...
0 votes
1 answer
48 views

Aligning FASTQs to FASTA reference

I'd like to align some FASTQs to an average mtDNA FASTA file that I have downloaded so I can have the human mtDNA isolated from those FASTQs. For that, I used bowtie2. Can I expect that after running ...
7 votes
1 answer
494 views

samtools mpileup empty when filtering out flags

I produced a bam file by aligning reads to a small set of synthetic sequences using bwa-mem. I am heavily filtering reads that are not paired and of a certain orientation. Applying the filtering, I ...
1 vote
1 answer
19 views

Discrepancy in Depth of Coverage Estimation between Pileup and samtools depth

I'm encountering a discrepancy in the depth of coverage assessment for specific coordinates when comparing results obtained from pileup files and samtools depth. I've processed pileup files and ...
3 votes
2 answers
4k views

Samtools sort: most efficient memory and thread settings for many samples on a cluster

We're preparing to analyze thousands of .bam files beginning with re-alignment, sorting, etc. Complicated question: Has anyone investigated the optimal thread and ...
1 vote
1 answer
72 views

Get a certain gene sequence from bam/vcf and reference

I need to get a fasta sequence of a certain gene for a certain worm strain that is different from reference. I have a reference genome, BAM for the strain of interest, and coordinates of the gene. I ...
1 vote
1 answer
34 views

I am trying to create a subset of 10k variants from 25-30 unmapped contigs of a g.vcf file including the header

My objective is to take a g.vcf.gz file and from 25-30 unmapped contigs with titles like "NW_020192317.1", I want to make a subset of ~10k variants from each of the unmapped contigs and make ...
3 votes
1 answer
193 views

low mapping percentage in bwa mem

After aligning paired-end reads to a reference genome, I am getting low percentage: ...
1 vote
1 answer
56 views

Create bam from separate sam and header

If I have multiple SAM files without header, and a header saved in a separate file, how do I convert that to a BAM file? One solution is to create intermediate files: ...
2 votes
2 answers
4k views

How to filter a SAM file by a bed file?

I have a large BAM file and I want to filter it by just what's defined in a bed file, and write it to a new file. Is it possible to do this with samtools, and if so, how? Is there a better tool I ...
1 vote
0 answers
195 views

Mapping statistics from the bam files

I would like to find the mapping statistics from the sorted bam files. Samtools flagstat gives the output only for a single file. What is the easiest way to find the mapping statistics for all ...
3 votes
1 answer
52 views

regex: samtools command to "refine" PacBio IsoSeq data?

I am working with preprocessed data (IsoSeq PacBio) and I cannot understand one of the steps: samtools view -b -e [rq] >= 0.9 flnc.bam What exactly was ...
16 votes
2 answers
10k views

Merge hundreds of small BAM files into a single BAM file

I am working with over a million (long) reads, and aligning them to a large genome. I am considering running my alignment jobs in parallel, distributing horizontally across hundreds of nodes rather ...
2 votes
2 answers
278 views

Problem with samtools command with a final hyphen

...
3 votes
1 answer
733 views

Nextflow Error: failed to read header from "-"

I am trying to run my nextflow pipeline, and have gotten this error: samtools sort: failed to read header from "-" I'm not sure why this error is ...
4 votes
2 answers
6k views

Extracting all reads from bam file which match read IDs in another file

I have a long list of read IDs of interest to me in a file called read_names.txt. it is simply in the format: ...
1 vote
0 answers
44 views

How do I filter reads from a bamfile based on 5' and 3' ends?

I have data in paired-end as well as single-end format for the same sample.I would like to split those two files into two per each, where one contains sequences that have 5' end and the other one has ...
4 votes
4 answers
183 views

Unable to open .bam file in C++ using SeqAn due to 'seqan::UnknownExtensionError'

I am trying to open .bam files in C++ to extract reads occurring at specific scaffolds and loci. I essentially want to call "samtools view sample.bam -o sample.sam scaffold:pos-pos" from C++....
3 votes
1 answer
180 views

CRISPR genome wide screen analysis using MAGeCK-- Loss of reads/sgRNA using MAGeCK count function?

Sorry if this question seems basic. I am trying to run the MAGeCK pipeline to analyze CRISPR knockout screen data produced by someone in my lab around 5 years ago. I was given the data as bam files ...
4 votes
0 answers
136 views

Write a bash script to run gatk, fix errors with input, and rerun until completion

I have a bam file that I want to run through GATK's SplitNCigarReads tool. Because of the way the bam file was generated, the program will often fail, with an error message stating: ...
2 votes
0 answers
137 views

Difference between pileup and mpileup in VarScan and samtools

I'm going to call variants with VarScan from a pileup files created with samtools. I realized that there are in general two major possibilities to call variants, pileup as well as mpileup. The VarScan ...
1 vote
0 answers
131 views

Trinity de novo transcriptome assembly: samtools view failed to add PG line to the header

I have assembled the transcriptome a plant species using Trinity. Here is the command: ...
2 votes
1 answer
933 views

how to retain reads with low mapping quality (MAPQ) scores when using samtools view -q

I have been using the -q option of samtools view to filter out reads whose mapping quality (MAPQ) scores are below a given ...
1 vote
1 answer
379 views

Different line length in fasta file

I am currently using VEP for variant annotation. I am facing an error as below: [E::fai_build_core] Different line length in sequence 'Pn9' I understand there is ...
2 votes
1 answer
213 views

Get number of reads with a single, (almost) exact match to the full length of a reference sequence

I can't find an answer to this in previous questions, so hoping someone can help me now. We have nanopore sequenced a PCR product, and I've filtered our reads to +/- 10 bp of the expected product ...
3 votes
1 answer
1k views

How to remove the unpaired reads in sam/bam files?

I have sam and bam files for the chimeric reads, which come from two different parts of the genome (For example, the first half of the read from part of Chromosome 1 and the second half of the read ...
0 votes
1 answer
380 views

Can I use samtools addreplacerg to replace multiple RG entries at the same time?

I have a bam file that contains two @RG lines: ...
2 votes
2 answers
396 views

Checking that two multiline FASTAs are identical (allowing for different order and lower/upper case)

Is there a good CLI tool that can diff two multiline fasta files, ignoring order, and comparing sequences with identical names with each other pairwise. Bonus points if lower/upper case is tolerated (...
0 votes
2 answers
54 views

BAM files with no RNAME and POS, how to map contents to SNPs?

I have a set of 4 .bam files containing the exome of an individual, around 400 MB each. I used samtools to generate a 2.4 GB .sam file out of one of the .bam files, and I found it contains lines with ...
2 votes
0 answers
380 views

How to extract reads that map exclusively to a single site with 1 or zero mismatches from BAM files

I generated BAM files (sorted by coordinates) by aligning human RNA reads against the human reference genome using BWA MEM and ...
2 votes
3 answers
561 views

Accessing .bam/.cram files from AWS S3?

What's the best/easiest way for accessing .bam/.cram files from S3? I have .bam/.bai .cram/.crai and .bed + .gff files that I want to make available easily to others so they can browse in IGV and ...
3 votes
0 answers
571 views

How to analyze an IGV alignment

I'm working on a project where I am analyzing the performance of an alignment workflow. My goal is to find regions in the resulting BAM file where there are outstanding discrepancies or anything that ...
1 vote
2 answers
1k views

Potential side effects of replacing read group tags in BAM file

I have a set of BAM files where the read group tags have some (default?) values, i.e.: @RG ID:RG0 LB:LB0 PU:PU0 SM:SM0 This creates issues in my downstream ...
3 votes
2 answers
189 views

Detect mutation context in a read of a sam file

After sequencing (Illumina) of some DNA, I generated a sam file through alignment of a fastq file (using Bowtie2). Instead of using variant calling programs, I want to know the specific variances, ...
4 votes
1 answer
442 views

samtools view command not found error

When I tried to use samtools to split a bam file based on different chromosomes, I used this command: samtools view input.bam -b chr21 | chr21.bam However, I get ...
2 votes
1 answer
46 views

Python package or CLI tool outputting mutations of sequence with respect to reference

I'm new to bioinformatics, and I'm looking for a tool that takes two FASTA files, one containing a reference, let's call it A.fasta, the other another sequence, let'...
4 votes
1 answer
611 views

BWA mem | samtools view: Intermittent parsing error

Update The issue was that bwa was running out of memory and failing, but that error wasn't floating to the top (see @Steve's answer, below). I was getting an error ...
2 votes
1 answer
437 views

Samtools sort: most efficient approach to sort a single sample after aligning split .fastq files

Related to my other question (Samtools sort: most efficient memory and thread settings for many samples on a cluster), we need to optimize samtools sort as we ...
0 votes
1 answer
4k views

How to Sort and Index a SAM file without converting it to BAM?

Generally, I use samtools to sort and index BAM files. Samtools works also with BGZF ...
4 votes
1 answer
911 views

How to get a MSA fasta from BAM/SAM?

I am working with paired end NGS miseq data from a viral genome with multiple timepoints. I have filtered and trimmed this data for quality and adapter sequences. I have then merged the filtered ...
5 votes
3 answers
535 views

Is there an efficient way to check an input BAM in R?

I'm writing a function in R for an R package which takes as input a BAM. ...
5 votes
1 answer
417 views

Displaying soft-clipped nucleotides in samtools tview

There are nicer genomics visualization tools available, but the samtools tview command is almost always my go-to for a quick first look at read alignments. I just ...
5 votes
3 answers
5k views

How to get fasta alignment file from SAM/BAM file?

I am not talking about consensus sequence, I know how to get consensus sequence using mpileup in samtools/bcftools. As I understand , SAM/BAM files are basically sequence alignment format so it's ...
1 vote
2 answers
531 views

How to extract all sequences mapped to a transcript from Kallisto output

This question has also been asked on Biostars I ran Kallisto with the --pseudobam option. How do I extract all the short reads that are mapped to a single transcript (e.g. ENST00000367969.8)? As a ...
4 votes
1 answer
295 views

Is there a tool that can perform a read-group-aware mpileup from a single file?

I would like to perform a samtools mpileup from a single file that contains thousands of read groups with different SM tags. I could split the bam by read group ...