Browse files

varia

  • Loading branch information...
1 parent 9aaea11 commit 6010d8ed4b94c714f6f06ac49a6b083c430a5462 @tiagoantao committed May 20, 2012
Showing with 33 additions and 19 deletions.
  1. +3 −0 36to37/README.txt
  2. +9 −3 meta/doMaladapted.py
  3. +0 −6 studies/doWork.py
  4. +1 −1 support/python/MEGA/__init__.py
  5. +20 −9 support/python/MEGA/study.py
View
3 36to37/README.txt
@@ -4,6 +4,8 @@ At the end you might want to meta/splitPlink.py
also patch alleles to hapmapXXX
Check at the end things for 37 QA
+We are running Version 2
+
VERSION 1
---------
DIR=mega-analysis/36to37
@@ -40,6 +42,7 @@ VERSION 2
DIR=mega-analysis/36to37
1. Make the meta data for ensembl
python $DIR/summariseEnsembl37.py
+You just need to do this once (extremelly slow process)
2. Convert coordinates
python $DIR/plink36to37.py XXX.bim > correct.pos 2>errors
View
12 meta/doMaladapted.py
@@ -18,9 +18,15 @@
sex=toks[2]
except IndexError:
sex=""
+ try:
+ region=toks[4]
+ country=toks[3]
+ except IndexError:
+ region=""
+ country=""
pop=toks[1].replace("(", " ").replace(")","").replace(" "," ")
ref="CEU"
- idInfo[id]=sex,pop+"700", ref
+ idInfo[id]=sex,pop+"700", ref, region, country
f.close()
f=open(MEGA.plinkDB + "/cambridge.fam")
@@ -32,8 +38,8 @@
print famId, sampId
continue
try:
- sex, pop, ref = idInfo[sampId]
- print("\t".join([famId, sampId, pop, "CEU", "", "", "", "", "", "700",
+ sex, pop, ref, region, country = idInfo[sampId]
+ print("\t".join([famId, sampId, pop, "CEU", region, "", country, "", "", "700",
"", "", "", "", "", "",
"", "", "", "", "", "", "", "", sex]))
except KeyError:
View
6 studies/doWork.py
@@ -274,12 +274,6 @@ def doAdmix(study, force, pops, ks, order):
for pop in pops:
indivs.extend(study.admix.getIndivsPop(pop))
admix(indivs, ks, study.admix.order, study.cacheDir)
- for cut in study.admix.ibd:
- logging.info("Admix IBD cut %f", cut)
- indivs = []
- for pop in pops:
- indivs.extend(study.admix.getIndivsPop(pop, cut))
- admix(indivs, ks, study.admix.order, study.cacheDir, cut)
os.chdir("..")
if len(study.admix.order)>0:
w = open(study.cacheDir + "/poporder", "w")
View
2 support/python/MEGA/__init__.py
@@ -194,7 +194,7 @@ def getHugo():
studyScripts = megaDir + os.sep + "studies"
metaScripts = megaDir + os.sep + "meta"
haploScripts = megaDir + os.sep + "haploStats"
-phasingScripts = megaDir + os.sep + "phasing2"
+phasingScripts = megaDir + os.sep + "phasing"
pcaScripts = megaDir + os.sep + "pca"
statScripts = megaDir + os.sep + "stats"
scripts = megaDir + os.sep + "scripts"
View
29 support/python/MEGA/study.py
@@ -26,7 +26,7 @@ def readRemove(fname):
return rems
-def readComplexPop(study, opDir, popListFile):
+def readComplexPop(study, opDir, popListFile, cut=None):
pops = {}
popsRemove = {}
try:
@@ -37,7 +37,10 @@ def readComplexPop(study, opDir, popListFile):
pops[popNames]=[]
for pop in popNames.split("+"):
logging.debug("%s popName %s pop %s", opDir, popNames, pop)
- pops[popNames].extend(list(study.pops.getIndivs(pop)))
+ if cut:
+ pops[popNames].extend(list(study.ibd.getIndivsPop(pop,cut,False)))
+ else:
+ pops[popNames].extend(list(study.pops.getIndivs(pop)))
popsRemove[popNames] = []
f.close()
except IOError:
@@ -151,10 +154,18 @@ def read(self):
i = 0
hasPCA = True
pops = set()
+ self.ibd = None
+ try:
+ f = open(self.myDir + os.sep + "ibd")
+ self.ibd = float(f.readline().rstrip())
+ f.close()
+ except IOError:
+ pass
while hasPCA:
pca, pcaRemove = readComplexPop(self.study,
self.myDir,
- "poplist." + str(i+1))
+ "poplist." + str(i+1),
+ self.ibd)
if pca == {}:
hasPCA = False
else:
@@ -171,6 +182,7 @@ def getIndivsPop(self, stNum, pop):
totalIndivs.remove((famId, sampId))
return totalIndivs
+
class Comparisons:
def __init__(self, study):
self.study = study
@@ -431,11 +443,10 @@ def read(self):
f.close()
except IOError:
self.pops = []
- self.ibd = []
+ self.ibd = None
try:
f = open(self.myDir + os.sep + "ibd")
- for l in f:
- self.ibd.append(float(l.rstrip()))
+ self.ibd = float(f.readline().rstrip())
f.close()
except IOError:
pass
@@ -447,12 +458,12 @@ def read(self):
except IOError:
self.order = {}
- def getIndivsPop(self, pop, cut=None):
+ def getIndivsPop(self, pop):
pops = pop.split("+")
indivs = []
for myPop in pops:
- if cut:
- indivs.extend(self.study.ibd.getIndivsPop(myPop, cut))
+ if self.ibd:
+ indivs.extend(self.study.ibd.getIndivsPop(myPop, self.ibd))
else:
indivs.extend(self.study.pops.getIndivsPop(myPop))
return indivs

0 comments on commit 6010d8e

Please sign in to comment.