Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

Handy commands

Extract bam according to a bed file

bedtools intersect -abam path/to/input.bam -b path/to/regions.bed > out.bam

Extract region of a VCF

vcftools --gzvcf /archive/runs/BSset1_bwamem_freebayes/ILL1EX1G6/S1/aln/freebayes_prim.vcf.gz --chr 6 --out fb_test --from-bp 29910200 --to-bp 29920000 --recode --recode-INFO-all

Missing out the --recode-INFO-all will remove all of the info from the filtered file

Extract bed regions of a VCF

vcftools --gzvcf /archive/runs/BSset1_bwamem_freebayes/ILL1EX1G6/S1/aln/freebayes_prim.vcf.gz --bed example.bed --out fb_test --recode --recode-INFO-all

CAUTION: This seems to miss the first line of a bed file! Maybe it expects a header.

Pandas shortcut

if you have big dataframes, with a lot of columns, just writing:

import pandas as pd
pd.options.display.width = 180

and than you can see all your column in one line (handy if your script is big)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.