10
votes
Accepted
How to count reads in bam per bed interval with bedtools
The order of -a and -b switched at some point. You want:
...
7
votes
Accepted
6
votes
Accepted
Merging bed records based on name
Although you don't mention it, I'm guessing you're using bedtools v2.26.0. Version 2.26.0 of groupBy has a bug in it, which you've encountered (it was fixed shortly after release, so you'll either ...
6
votes
Merging regions according to their identifier
If I understand correctly, you could create dummy chromosomes made by merging chromosome and identifier, merge with bedtools, split back chromosomes and identifiers. E.g.
...
5
votes
Accepted
How to create a .bed file from .fasta?
Here is a fun little python script I cooked up for the occasion. It will take a standard fasta file as a command-line argument and turn it into the proper bed format. Using your example fasta:
...
5
votes
Parse out exon coordinates from bed file for each gene
There are multiple ways to go about it. On the command line you can make a 1 line BED file:
chr1 11868 12227
And then ...
5
votes
Accepted
5
votes
Accepted
How to best detect the "peaks" in RNA-seq data that are not assigned to any gene?
Basically what you're discovering is that there are unannotated expressed features, so your task isn't really finding peaks, but rather finding novel expressed transcripts. For that, you can use ...
4
votes
Merging bed records based on name
You could do this with the CGAT toolkit:
cgat bed2bed --method=merge --merge-by-name -I bed_with_gene_ids.bed
Installing such ...
4
votes
How to create a .bed file from .fasta?
I'm assuming the FASTA header contains all the information you want. You can easily generate a proper bed file with Biopython:
...
4
votes
How can I calculate coverage at single bases using a bam file?
Note: not yet tested, so there may be some additional fiddling with command line options needed
The per-base depth can be obtained from samtools depth (-a includes zero-coverage positions):
...
4
votes
How can I calculate coverage at single bases using a bam file?
git clone https://github.com/lh3/htsbox
cd htsbox && make
./htsbox pileup -cCf ref.fa aln.bam | less -S
This output a VCF containing positions covered by ...
4
votes
How to do `bedtools intersection` using pandas alone?
I don't think Pandas has this implemented functionality out-of-the-box. Even if it did, solutions not designed specifically for bioinformatics probably rarely handle intervals on different chromosomes ...
4
votes
bedtools intersect on very large .bam file - -sorted confusion
It sounds like bedtools is behaving properly. The bam file is sorted by read name only if you used the -n option in samtools sort...
4
votes
Accepted
bedtool intersect multiple bed files
If you want to find the intersection between ALL your bedfiles, you can try multiIntersectBed (available since bedtools 2.14.3).
It should work like this :
...
3
votes
Merging regions according to their identifier
Here is a fairly simple (and hopefully readable) native Python solution. It assumes that the bed file is sorted prior to parsing:
...
3
votes
Accepted
How to split bedfile into non-overlapping regions and compute aggregation function on duplicate segments
To make disjoint intervals, you could use BEDOPS bedops --partition, piping to bedmap --mean to get the mean signal over ...
3
votes
How to create a .bed file from .fasta?
If your headers are always of the form >chrZ:a-b, where chrZ is a chromosome name, a is a ...
3
votes
How to create a .bed file from .fasta?
The UCSC format you linked to isn't a BED file, your method should never produce it. What you posted as your desired output is also not a BED file. Below is a BED file:
...
3
votes
Accepted
Comparing two files with overlapping regions and get their associated information
You can use bedtools intersect and cut the results:
...
3
votes
Accepted
Merging regions according to their identifier
The following python script will do what you want and should be relatively memory efficient. It processes a single chromosome at a time, so either sort the input or ensure that at least entries in a ...
3
votes
Parse out exon coordinates from bed file for each gene
Via BEDOPS bedops -n and Unix I/O streams:
$ echo -e "chr1\t11868\t12227" | bedops -n 1 exon.bed - > answer.bed
Or, if you ...
3
votes
Using column 2 of one file to match with two columns of another file, and append
Pipe a modified form of the second file to BEDOPS bedmap and the first file, then pipe that result to cut out desired columns:
...
3
votes
Merging bed records based on name
You can do this easily with Hail. Hail primarily uses BED files to annotate genetic datasets (see the last annotate_variants_table example), but you can manipulate BED files using Hail's general ...
3
votes
Unable to install bedtools on windows 10 ubuntu
My personal advice would be to avoid compiling tools like this if you can avoid it, especially where you are using a "barebones" setup like the one you get with WSL Ubunutu as you'll almost always run ...
3
votes
Accepted
Extracting the number SNP in each range
There is like a thousand different ways how to achieve this. You could use a specialised software for this (like bedtools) or calculate it simply in R.
R solution: You can make a function that ...
3
votes
Accepted
bedtools feature out of bounds
There is no chromosome named chr10, but there is one named 10. The problem is that you're mixing chromosome name systems with a ...
3
votes
Accepted
How to detect bedtools version used by pybedtools (in order to correctly preserve strand information when merging gtf records)
pybedtools assumes that bedtools is in your path and bedtools itself will return the version with bedtools --version. So:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
bedtools × 59bed × 14
sam × 7
coverage × 7
python × 5
vcf × 5
pybedtools × 5
sequence-alignment × 4
samtools × 4
r × 3
fasta × 3
sequence-analysis × 3
ngs × 3
chip-seq × 3
wgs × 3
rna-seq × 2
genome × 2
snp × 2
cnv × 2
peak-calling × 2
macs2 × 2
interval × 2
merge × 2
scrnaseq × 1
phylogenetics × 1