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
42 votes
4 answers
56k 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,305
20 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,166
19 votes
2 answers
12k 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
  • 13k
18 votes
3 answers
4k 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
18 votes
3 answers
13k 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
  • 777
17 votes
3 answers
5k 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
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 ...
Scott Gigante's user avatar
15 votes
1 answer
4k 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
  • 777
14 votes
1 answer
870 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,373
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
  • 744
14 votes
1 answer
232 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
13 votes
5 answers
1k 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
11 votes
2 answers
378 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
967 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 ...
rightskewed's user avatar
11 votes
1 answer
275 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
2 answers
283 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
  • 744
9 votes
2 answers
11k 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
1 answer
681 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
9 votes
2 answers
1k 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
  • 777
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,561
9 votes
2 answers
5k 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,274
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 ...
EB2127's user avatar
  • 1,373
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
443 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,274
8 votes
3 answers
3k 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
  • 9,352
8 votes
3 answers
3k 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
2 answers
545 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,417
8 votes
1 answer
261 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,656
8 votes
0 answers
436 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
671 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
3 answers
3k 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
1 answer
749 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,274
7 votes
2 answers
589 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,373
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,373
7 votes
1 answer
491 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
774 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
304 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,449
7 votes
1 answer
175 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
  • 13k
7 votes
1 answer
702 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,274
7 votes
1 answer
429 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,274
7 votes
1 answer
570 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
471 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
  • 9,352
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
5 answers
3k views

Subset smaller BAM to contain several thousand rows from multiple chromosomes

There are many cases whereby I would like to subset a BAM to create a small file in order to work with (e.g. algorithmic testing, debugging, etc.) Normally I do the following, which will subset the ...
EB2127's user avatar
  • 1,373
6 votes
1 answer
298 views

How to validate that BAMs have been downloaded correctly?

I currently have several hundred BAM files which were downloaded by someone else. These have remained untouched---before working with them, I would like to double-check that these BAMs have been fully ...
EB2127's user avatar
  • 1,373
6 votes
3 answers
751 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
6 votes
2 answers
4k 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
  • 952
6 votes
1 answer
577 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
  • 777
6 votes
1 answer
2k views

Read counts from BAM file

I have few BAM files which are generated from Ion Torrent Server (ampliseq) aligned to hg19 genome. I want to extract read counts from the bam files and I know that "featureCounts" can be used for ...
stack_learner's user avatar

1
2 3 4 5