As of May 31, 2023, we have updated our Code of Conduct.

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
2 votes
2 answers
2k 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
38 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
24 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
9k 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
149 views

Problem with samtools command with a final hyphen

...
3 votes
1 answer
97 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
5k 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
35 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
163 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
61 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
99 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
71 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
64 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
370 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
202 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
65 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
645 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
186 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: ...
1 vote
2 answers
57 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
39 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
293 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
508 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
262 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
532 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
126 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
280 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
2 answers
2k 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 ...
2 votes
1 answer
43 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
333 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
193 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
2k 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
750 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
419 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
356 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
4k 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
367 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
238 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 ...
8 votes
7 answers
9k views

How to subset a BAM by a list of QNAMEs?

I have a text file 'qnames.txt' with QNAMEs in the following format: EXAMPLE:QNAME1 EXAMPLE:QNAME2 EXAMPLE:QNAME3 EXAMPLE:QNAME4 EXAMPLE:QNAME5 I would like to ...
1 vote
1 answer
54 views

Is there a sam flag for all&none of the reads?

a. Is there a SAM flag that specifies all reads? b. Is there a SAM flag that specifies none of the reads? So that if I run samtools view -f (a) -F (b) the result will be all reads of the file (as if ...
0 votes
1 answer
148 views

Convert VCF file to mpileup.txt

I am working on an iterative analysis that uses orthologous pipelines that require mpileup.txt files as input for a visualization step. This requires me to convert VCF files to mpileup.txt. This ...
2 votes
1 answer
469 views

Cuffmerge: EOF marker is absent. The input is probably truncated

I need to merge my all transcripts.gtf from cufflinks output follow this command line : cuffmerge -o merged_gtf_output -p 15 -s ref.fasta -g anot.gtf assembly.txt ...
3 votes
5 answers
6k views

How to create a .bed file from .fasta? [duplicate]

I have some problems in creating a .bed file for hg19, so I will be able to visualize the .bed file in IGV. The .fasta file contains rows of this form: ...
2 votes
1 answer
44 views

Counting the co-occurrence of variants A and B in an aligned sequencing read

I need some help getting started on this project. To simplify we want to be able to quantify the occurrence of 3 variants on each sequencing read in an alignment file as a proxy measurement for ...
1 vote
1 answer
378 views

How to convert multiple single-end bam files to fastq using samtools

Hi I am trying to convert bam files generated from Ion Torrent Proton sequencing to fastq format so that I can upload them to ...
0 votes
1 answer
368 views

Is it normal to have a smaller bam file after merging bam files?

I have 2 bam files that belong to the same sample and I merged them with samtools merge. And after merging, I realized that the merged version is a bit smaller than ...
1 vote
2 answers
234 views

Can HTSlib extract bam reads occurring in a specific region without iterating through the whole file?

I am using htslib/sam.h to write a C++ program. As part of this program, I must extract reads occurring on specific scaffolds in specific regions from a bam file. Essentially, I want to perform the ...
11 votes
3 answers
6k views

Converting a VCF into a FASTA given a reference with Python, R

I am interested in converting a VCF file into a FASTA file given a reference sequence with Python or R. Samtools/BCFtools (Heng Li) provides a Perl script ...
5 votes
1 answer
284 views

Samtools/bcftools calling indels in noisy reads

I have very noisy nanopore reads and am trying to call SNPs/indels. I'm runinig into some trouble when truing to use the samtools mpileup | bcftools call ...
1 vote
0 answers
512 views

Conversion of SAM to BAM files

I am very new to micro RNA analysis. I have been using H. sapiens, GRCh38 + major index as given in the Bowtie Website to align with my trimmed FASTQ file . The command I am using to make very ...
5 votes
0 answers
203 views

convert supplementary reads to primary in sam or bam

I have a problem with a tool, that possibly ignores supplementary reads. I want to find out a bit how this tool works by converting all supplementary reads to primary reads, and then change the names ...