This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to excute plink on colab

I am practicing with the book "bioinformatics with python cookbook".
In the part of POPULATION GENETICS with PLINK files,
I am using colab instead of jupyter notebook and find some errors. 'hapmap01.map' file is not generated.
So, the function "get_non_auto_SNPs" doesn't work.

Plink is usable on colab?
How could I solve this problem?

Thanks in advance.

Sub-sampling

In [5]: 
os.system('plink --recode --file hapmap3_r2_b36_fwd.consensus.qc.poly --noweb --out hapmap10 --thin 0.1 --geno 0.1')
os.system('plink --recode --file hapmap3_r2_b36_fwd.consensus.qc.poly --noweb --out hapmap1 --thin 0.01 --geno 0.1')

Getting only autosomal data

In [6]:
def get_non_auto_SNPs(map_file, exclude_file):
    f = open(map_file)
    w = open(exclude_file, 'w')
    for l in f:
        toks = l.rstrip().split('\t')
        chrom = int(toks[0])
        rs = toks[1]
        if chrom > 22:
            w.write('%s\n' % rs)
    w.close()
In [7]:
get_non_auto_SNPs('hapmap10.map', 'exclude10.txt')
get_non_auto_SNPs('hapmap1.map', 'exclude1.txt')
#get_non_auto_SNPs('hapmap3_r2_b36_fwd.consensus.qc.poly.map', 'exclude.txt')

In [8]:
!plink --recode --file hapmap10 --noweb --out hapmap10_auto --exclude exclude10.txt
!plink --recode --file hapmap1 --noweb --out hapmap1_auto --exclude exclude1.txt
#geno!!!
#!plink --recode --file hapmap3_r2_b36_fwd.consensus.qc.poly --noweb --out hapmap_auto --exclude exclude.txt

plink1 plink2

software error

0 answers

No answers yet.

Log in to answer this question.