Skip to content

Instantly share code, notes, and snippets.

@mattions
Created September 21, 2015 10:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattions/e360bc401a17001a08b2 to your computer and use it in GitHub Desktop.
Save mattions/e360bc401a17001a08b2 to your computer and use it in GitHub Desktop.

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