Skip to main content

Questions tagged [sam]

Use this tag for questions specifically related to the text SAM format. For general questions about the SAM/BAM formats use the tag BAM.

Filter by
Sorted by
Tagged with
41 votes
4 answers
61k views

What is the difference between FASTA, FASTQ, and SAM file formats?

I'd like to learn the differences between 3 common formats such as FASTA, FASTQ and SAM. How they are different? Are there any benefits of using one over another? Based on Wikipedia pages, I can't ...
kenorb's user avatar
  • 1,293
21 votes
12 answers
2k views

Random access on a FASTQ file

I would like to select a random record from a large set of n unaligned sequencing reads in log(n) time complexity (big O ...
winni2k's user avatar
  • 2,286
20 votes
4 answers
15k views

How can I downsample a BAM file while keeping both reads in pairs?

I know how to downsample a BAM file to lower coverage. I know I can randomly select lines in SAM, but this procedure can't guarantee two reads in a pair are always sampled the same time. Is there a ...
medbe's user avatar
  • 847
19 votes
2 answers
14k views

Obtaining uniquely mapped reads from BWA mem alignment

This is based on a question from betsy.s.collins on BioStars. The original post can be found here. Does anyone have any suggestions for other tags or filtering steps on BWA-generated BAM files that ...
gringer's user avatar
  • 14.3k
18 votes
1 answer
5k views

What is the difference between samtools, bamtools, picard, sambamba and biobambam?

After some google searches, I found multiple tools with overlapping functionality for viewing, merging, pileuping, etc. I have not got time to try these tools, so will just see if anyone already know ...
medbe's user avatar
  • 847
17 votes
3 answers
5k views

Convert a BAM file from one reference to another?

I have a set of BAM files that are aligned using the NCBI GRCh37 human genome reference (with the chromosome names as NC_000001.10) but I want to analyze it using a BED file that has the UCSC hg19 ...
morgantaschuk's user avatar
17 votes
3 answers
6k views

BAM to BigWig without intermediary BedGraph

I have a pipeline for generating a BigWig file from a BAM file: BAM -> BedGraph -> BigWig Which uses bedtools genomecov ...
Nathan S. Watson-Haigh's user avatar
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 ...
Scott Gigante's user avatar
15 votes
5 answers
2k views

Good / recommended way to archive fastq and bam files?

We have a lot of Illumina sequenced exome data. Currently we are using spring for its great lossless compression, but we are looking if there is anything better (and most preferably opensource) which ...
Karthik Nair's user avatar
14 votes
1 answer
965 views

Why would someone use a CRAM instead of a BAM?

I had this question from a graduate student yesterday, and I was stuck. What should I say? Why use a CRAM instead of a BAM? When is it a good idea to use a CRAM instead of a BAM? When is it a bad ...
EB2127's user avatar
  • 1,423
14 votes
1 answer
2k views

Are soft-clipped bases used for variant calling in samtools + bcftools?

If there are soft clipped base pairs specified in the CIGAR string for a read in a SAM/BAM file, will these be used for variant calling in a samtools + bcftools workflow? The GATK HaplotypeCaller, ...
mattm's user avatar
  • 754
13 votes
1 answer
238 views

Compare alignment quality of multiple sequencing runs aligned against the same reference genome

I have run Oxford Nanopore Technologies' MinION sequencing on the same DNA sample using three flowcells, each aligned against the same reference genome (E.coli K12 MG1655) using both BWA MEM and ...
Scott Gigante's user avatar
11 votes
2 answers
432 views

Do variant calls change when you call from CRAM?

We're considering switching our storage format from BAM to CRAM. We work with human cancer samples, which may have very low prevalence variants (i.e. not diploid frequency). If we use lossy CRAM to ...
morgantaschuk's user avatar
11 votes
1 answer
1k views

Quantifying reads mapping to multiple loci

I have been using STAR for our RNA-Seq samples. The final.out log file reports percentage of uniquely mapped reads along with percentage of reads that map to ...
Saket Choudhary's user avatar
11 votes
1 answer
348 views

Can I create a CRAM file with a relative reference path?

I’m trying to create a CRAM file that stores its path to the FASTA reference as a relative path, rather than an absolute path, so that I can move the files around. Unfortunately I can’t get this to ...
Konrad Rudolph's user avatar
10 votes
1 answer
716 views

Why does this human bam file only have one copy of each chromosome?

As we know that in human DNA sequence, one copy of chromosome comes from mother's DNA and another copy comes from father's DNA so as to form two copies of each chromosome in human DNA. So, if we ...
Lot_to_learn's user avatar
10 votes
2 answers
291 views

What are the de facto required fields in a SAM/BAM read group?

The SAM specification indicates that each read group must have a unique ID field, but does not mark any other field as required. I have also discovered that htsjdk throws exceptions if the sample (...
mattm's user avatar
  • 754
9 votes
2 answers
12k views

Converting a BAM file into VCF

I have NGS illumina RNA-seq reads from M. musculus (mm10). I am trying to find variants along the strand portion of the reads in the refseq (mm10). I mapped a pair of sequence files and generated a ...
Lou_A's user avatar
  • 361
9 votes
2 answers
2k views

Why do BAM files created by different tools have different file sizes?

I have a BAM created by Picard. I want to filter alignments by flags with samtools view. However, I noticed that even if I apply no filters, the output BAM is ...
medbe's user avatar
  • 847
9 votes
1 answer
5k views

How to count reads in bam per bed interval with bedtools

I recently installed Ubuntu 16.04 (because I was still using 12.04). But it seems my bedtools scripts don't work properly anymore. I can't figure out how to use the new bedtools for my old ways. What ...
benn's user avatar
  • 3,581
9 votes
2 answers
6k views

samtools depth print out all positions

I am trying to use samtools depth (v1.4) with the -a option and a bed file listing the human chromosomes chr1-chr22, chrX, chrY, and chrM to print out the coverage ...
719016's user avatar
  • 2,324
9 votes
2 answers
788 views

How to import a large amount of .bed, .gff, .vcf, .paf, .sam files into an SQL database?

Are there best practices to load different bioinformatics file formats such as VCF, BED, GFF, and SAM to SQL databases? I am wondering how people out there do that efficiently. All of these three ...
0x90's user avatar
  • 1,437
8 votes
7 answers
12k 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 ...
EB2127's user avatar
  • 1,423
8 votes
4 answers
1k views

How to manipulate a reference FASTA or bam to include variants from a VCF?

I have some software which takes fastas as the input. I need to include SNVs and InDels from a VCF into the reference hg38 and then use this. The problem is, I don't know of an algorithmically sound ...
ShanZhengYang's user avatar
8 votes
2 answers
453 views

Convert bam file to highly compressible bam

I have a large collection of bam files and I want to post-process each of them into another bam where I can make queries about: the reads position and pair-endness, insert sizes, MAPQ and other ...
719016's user avatar
  • 2,324
8 votes
3 answers
4k views

How can I count the number of reads that support a variant in a bam file?

I am calling variants from a human sample using bwa mem to align the reads and gatk to call the variants. I'm trying to understand why a specific variant was not called in my sample. I have checked ...
terdon's user avatar
  • 10.2k
8 votes
1 answer
763 views

Why most aligners do not output the "X" CIGAR operation?

As I read the SAM spec, the "X" CIGAR operator represents a mismatch. This seems useful as we can know where are the mismatches without looking at the reference genome. However, many popular aligners ...
medbe's user avatar
  • 847
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 ...
Konrad Rudolph's user avatar
8 votes
3 answers
4k views

How to merge sam files together with adding read groups

I have three sequencing libraries of single individual mapped to a reference using bwa-mem. I would like to merge the three unsorted ...
Kamil S Jaron's user avatar
8 votes
1 answer
293 views

Convert local alignments to spliced alignments in SAM file

I mapped RNA reads to reference genome, using LAST in split mode, and converted the MAF alignment to SAM with maf-convert. My problem is that the transcripts are not reported in a spliced manner, ...
aechchiki's user avatar
  • 2,676
8 votes
0 answers
487 views

How can I read multiple different regions from a BAM file in R?

I’m trying to process BAM records (of a coordinate-sorted, indexed BAM file) successively in fixed-size, non-overlapping, sliding genome coordinate windows. Unfortunately I am unable to read records ...
Konrad Rudolph's user avatar
7 votes
3 answers
801 views

Is there a way to retrieve several SAM fields faster than `samtools view | cut -f`?

I am constructing a bit of software which pipes the outputs of the bam file via samtools view into a script for parsing. My goal is to (somehow) make this process ...
ShanZhengYang's user avatar
7 votes
1 answer
3k views

Index a BAM file using pysam

(How) can you index a BAM file using pysam? When I tried the intuitive pysam.index I got: ...
Kamil S Jaron's user avatar
7 votes
3 answers
4k views

How to check whether all BAM read contain defined read groups?

I'm trying to investigate whether there are errors within my BAM. After looking at the BAM header to see whether the read groups exists (using samtools, i.e. ...
ShanZhengYang's user avatar
7 votes
2 answers
5k views

Get the mapping statistics of a single read from a BAM file

I have a BAM file, and I have a read ID. What is the simplest way to get mapping statistics of that read in human-readable format? E.g. I might want: % identity of aligned bases; number of insertions ...
roblanf's user avatar
  • 962
7 votes
1 answer
836 views

ethnicity check either from bam or vcf files

What tool could I use to check the ethnicity of a human bam or vcf file? I would like to use the results as a QC check to know whether a given sample or set of samples match the ethnicity information ...
719016's user avatar
  • 2,324
7 votes
2 answers
686 views

How does htslib/samtools access optional BAM fields?

I am confused regarding how various software libraries deal with optional fields in a BAM: Based upon the BAM specification, there are 11 mandatory fields to a BAM: ...
EB2127's user avatar
  • 1,423
7 votes
1 answer
2k views

How to remove all BAM read groups from all reads (not just the header)?

I have problem with one my BAMs---it appears to have invalid read groups. Normally when I have such a problem, I remove all the read groups from the BAM header as follows: ...
EB2127's user avatar
  • 1,423
7 votes
4 answers
5k views

Is there a command line tool to split a SAM/BAM file by CB (cell barcode) tag?

I have a BAM file from a single cell sequencing experiment. Each read has had the cell barcode annotated in the CB tag. Some reads do not have a ...
winni2k's user avatar
  • 2,286
7 votes
1 answer
557 views

Split FASTQ and matching BAM into matching chunks

I am running a slow downstream analysis on a large set of nanopore reads (approx 3 million), and would like to split them into smaller chunks, run the analysis in massively parallel, and then ...
Scott Gigante's user avatar
7 votes
2 answers
3k views

Extracting the CIGAR string from a BAM via Python?

Is there a standard method in Python to extract a CIGAR string from the BAM? There are great libraries which parse the CIGAR, e.g. https://pypi.python.org/pypi/cigar/0.1 ...
ShanZhengYang's user avatar
7 votes
1 answer
918 views

Filtering bases based on phred qualities with pysam

Is there a way to filter bases in BAM files based on phred quallities through python's pysam ? I have a code here that Takes the nucleobases per position from a BAM file using pysam's pileup ...
Ammar Sabir Cheema's user avatar
7 votes
1 answer
329 views

scanBam from Rsamtools is not importing one of my reads into R

I have this read in my BAM file. It maps on chromosome 1. I open this BAM file in IGV, and I can see the alignment on chromosome 1. But when I open this file in R with Rsamtools: ...
Biomagician's user avatar
  • 2,459
7 votes
1 answer
184 views

How can I speed up INDEL calling/correction on BAM files?

The samtools mpileup command has quite a neat feature that it is able to correct mapping errors associated with misalignment of INDELs. By default, the ...
gringer's user avatar
  • 14.3k
7 votes
1 answer
828 views

low-memory high-speed replacement for Picard MarkDuplicates

I am running Picard MarkDuplicates with the following parameters below. On the file described, it takes about 41.6Gb of RAM memory and about 20-25 minutes to compute (only uses 1 core AFAICS). ...
719016's user avatar
  • 2,324
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 ...
719016's user avatar
  • 2,324
7 votes
1 answer
642 views

Reject reads with low quality bases from a Bam file through pysam

I have a code below: ...
Ammar Sabir Cheema's user avatar
6 votes
1 answer
725 views

Why do SAM and BAM use different coordinate systems?

BAM files are, at least as far as I know, simply binary compressed versions of SAM files. They have the exact same information and are used in the same way. Why then does the SAM format use a 1-based ...
terdon's user avatar
  • 10.2k
6 votes
3 answers
1k views

Total reads aligning to each reference within a bam file

I have two PCR amplicons that have been multiplexed and sequenced using the nanopore minion. I have aligned the fastq reads using minimap2 with a reference file containing both amplicon sequences and ...
CM3's user avatar
  • 63
6 votes
3 answers
890 views

Generating the reconstructed alignment from BAM

I have a (small) BAM file with CIGAR and MD fields. Question 1: What tools exists in Python and/or R to reconstruct the alignment between the reference and the read in a BAM? Given that this is a ...
ShanZhengYang's user avatar

1
2 3 4 5