This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pandas import crosstab | |
def pyfreq(v1, v2 = None, weight = None, order = ''): | |
if v2 is not None: | |
if weight is not None: | |
cnt = crosstab(v1, v2, weight, aggfunc = sum, margins = True, dropna = False) | |
else: | |
cnt = crosstab(v1, v2, margins = True, dropna = False) | |
if order == 'freq': | |
cnt.iloc[:-1, :] = cnt.iloc[:-1, :].sort_values('All', ascending = False).values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fromFile=Mouse_ESC.meth | |
indexFile=CpGs-mm9Tohg19.bed | |
toFile=Mouse_ESC-hg19.meth | |
$fastLiftOver -f $fromFile -i $indexFile -t $toFile -v | |
# sort output and merge sites mapped to the same location | |
export LC_ALL=C; | |
tmpfile=$(mktemp); | |
wc -l $toFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
promoters=~qiangson/panfs/data/human/hg18/gene/promoter-nr.bed | |
CpGs=~qiangson/panfs/co-methylation/methylomes/Berman-Human-2012-Human_ColonCancer-results-Human_ColonCancer_Meth.bed | |
~qiangson/app/bedtools/bin/intersect $promoters $CpGs \ | |
|cut -f4-6|uniq -c \ | |
|awk '{print $2,$3,$4,2*$1/($4-$3);}' > CpG-densities.bed | |