Skip to content

Commit

Permalink
Wd (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
WardDeb authored Nov 14, 2022
1 parent fd803a6 commit 77c771d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 16 deletions.
20 changes: 11 additions & 9 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
CHANGES
=======

* non-canonical deeptools to get rid of comp problem
* ignore
* cap snakemake -> tmp & profile
* rewrite - after alsieve
* ignore build
* purge&ignore
* restructure to make code less obfuscated + pave way for multicomps
* egg exclude
* RPKM bigwigs
* include frig fig, ignore > 1000 for fragsize, set threads motif cluster
* uropa change defaults + checks gtf
* make to preserve key order in yaml dump. Purge ESS
* switch to gene for uropa annotation as default
* Update README.md
* Wd (#9)
* meme working
* babysteps into tobias/motifs
* purgebuild
* Wd (#8)
* Wd (#6)
* update readme
* Shuffling
* fix batch vs non batch in 1 run
Expand Down
44 changes: 40 additions & 4 deletions src/AOS/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ def plotfragsize(frags):
for i,r in df.iterrows():
size = int(r[0])
occ = int(r[1])
for k in repeat(size, occ):
reps.append([r['Sample'], size])
if size < 1000:
for k in repeat(size, occ):
reps.append([r['Sample'], size])
df = pd.DataFrame(reps)
df.columns = ['sample', 'size']
df.sort_values(by=['sample'], inplace=True)
Expand Down Expand Up @@ -238,15 +239,15 @@ def peak_boundaries(peaks, genomefa, of):
with open(genomefa) as f:
for line in f:
if line.startswith('>'):
header = line.strip().replace('>', '')
header = str(line.strip().replace('>', '').split(' ')[0])
chromdic[header] = 0
else:
chromdic[header] += len(line.strip())
bedlis = []
peakchange = 0
with open(peaks) as f:
for line in f:
chrom = line.strip().split()[0]
chrom = str(line.strip().split()[0])
start = int(line.strip().split()[1])
end = int(line.strip().split()[2])
if end > chromdic[chrom]:
Expand All @@ -266,3 +267,38 @@ def peak_boundaries(peaks, genomefa, of):
header=False,
index=False
)

def PCA_colors(config):
colors = [
'#1f77b4',
'#ff7f0e',
'#2ca02c',
'#d62728',
'#9467bd',
'#8c564b',
'#e377c2',
'#7f7f7f',
'#bcbd22',
'#17becf'
]
if config['files']['samplesheet']:
sdf = pd.read_csv(
config['files']['samplesheet'],
sep='\t',
header=0
)
sdf = sdf.set_index('sample')
sdf = sdf.loc[config['samples']]
colDic = {}
colIx = 0
for s in sdf.iloc[:,[0]].values:
if s[0] not in colDic:
colDic[s[0]] = colors[colIx]
colIx += 1
PCAstr = "--colors"
for s in sdf.iloc[:,[0]].values:
PCAstr += " \"{}\"".format(
colDic[s[0]]
)
return (PCAstr)
return ("")
1 change: 1 addition & 0 deletions src/AOS/rules/motifs.smk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ rule clustermotifs:
output:
'motifs_clustered/clusteredmotifs_consensus_motifs.meme'
conda: config['envs']['tobias']
threads: 10
shell:'''
TOBIAS ClusterMotifs -m {input} -t 0.4 -a meme -p clusteredmotifs -o 'motifs_clustered' --dist_method seqcor
'''
Expand Down
8 changes: 6 additions & 2 deletions src/AOS/rules/peaks.smk
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from AOS.helper import peak_boundaries
from AOS.helper import PCA_colors

rule lnBams:
input:
os.path.join(config['dirs']['bamdir'], "{sample}.bam")
Expand Down Expand Up @@ -164,11 +166,13 @@ rule multibigwigsum:

rule plotPCA:
input:
'peakset/counts.bw.npz'
peakset = 'peakset/counts.bw.npz'
output:
'figures/PCA.png'
threads: 1
params:
colstr = PCA_colors(config)
conda: config['envs']['seqtools']
shell:'''
plotPCA --corData {input} -o {output} --transpose --ntop 5000
plotPCA --corData {input.peakset} -o {output} --transpose --ntop 5000 {params.colstr}
'''
3 changes: 2 additions & 1 deletion src/AOS/workflow.smk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def geto():
'figures/mitofraction.png',
'qc/fragsize.tsv',
'figures/alignmentsieve.png',
'figures/fragmentsizes.png'
'figures/fragmentsizes.png',
'figures/fripscores.png'
]
)
# Differential
Expand Down

0 comments on commit 77c771d

Please sign in to comment.