Skip to content

Commit ddf166a

Browse files
committed
os import error
1 parent 15d1d07 commit ddf166a

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

src/GPS/spatial_ldsc_multiple_sumstats.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import os
2+
import numpy as np
3+
import pandas as pd
4+
15
import argparse
26
import logging
37
import multiprocessing
@@ -13,9 +17,6 @@
1317

1418
logger = logging.getLogger(__name__)
1519

16-
import numpy as np
17-
import pandas as pd
18-
1920

2021
# %%
2122
def _coef_new(jknife):
@@ -262,7 +263,6 @@ def run_spatial_ldsc(config: SpatialLDSCConfig):
262263
# args = parser.parse_args(args_list)
263264
else:
264265
args = parser.parse_args()
265-
import os
266266

267267
os.chdir('/storage/yangjianLab/chenwenhao/tmp/GPS_Height_debug')
268268
TASK_ID = 16

test/GPS-snakemake-workflow-macaque.smk

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ sample_names.remove('T825_macaque3') # due to 25% of spot don't have spatial coo
2424

2525
annotation = "SubClass"
2626
data_type = "SCT"
27-
# sample_names = ['T584_macaque2']
27+
sample_names = ['T584_macaque2']
2828
num_processes = 20
2929

3030
rule all:
@@ -123,8 +123,6 @@ rule latent_to_gene:
123123
latent_representation="latent_GVAE",
124124
num_neighbour=51,
125125
num_neighbour_spatial=201,
126-
fold=1.0,
127-
pst=0.2,
128126
species='MACAQUE_GENE_SYM',
129127
gs_species='/storage/yangjianLab/songliyang/SpatialData/homologs/macaque_human_homologs.txt',
130128
gM_slices=None,
@@ -148,8 +146,6 @@ GPS run_latent_to_gene \
148146
--latent_representation {params.latent_representation} \
149147
--num_neighbour {params.num_neighbour} \
150148
--num_neighbour_spatial {params.num_neighbour_spatial} \
151-
--fold {params.fold} \
152-
--pst {params.pst} \
153149
{'--species ' + params.species if params.species is not None else ''} \
154150
{'--gs_species ' + params.gs_species if params.gs_species is not None else ''} \
155151
{'--gM_slices ' + params.gM_slices if params.gM_slices is not None else ''}
@@ -166,11 +162,14 @@ rule generate_ldscore:
166162
done='{sample_name}/generate_ldscore/{sample_name}_generate_ldscore_chr{chrom}.done'
167163
params:
168164
ld_score_save_dir='{sample_name}/generate_ldscore',
169-
gtf_file="/storage/yangjianLab/songliyang/ReferenceGenome/GRCh37/gencode.v39lift37.annotation.gtf",
165+
gtf_annotation_file="/storage/yangjianLab/songliyang/ReferenceGenome/GRCh37/gencode.v39lift37.annotation.gtf",
170166
bfile_root="/storage/yangjianLab/sharedata/LDSC_resource/1000G_EUR_Phase3_plink/1000G.EUR.QC",
171167
keep_snp_root="/storage/yangjianLab/sharedata/LDSC_resource/hapmap3_snps/hm",
172-
window_size=50000,
173-
spots_per_chunk=1000,
168+
gene_window_size=50000,
169+
enhancer_annotation_file=None,
170+
snp_multiple_enhancer_strategy='max_mkscore',
171+
gene_window_enhancer_priority=None,
172+
spots_per_chunk=5000,
174173
ld_wind=1,
175174
ld_unit="CM"
176175
benchmark: '{sample_name}/generate_ldscore/{sample_name}_generate_ldscore_chr{chrom}.done.benchmark'
@@ -179,11 +178,25 @@ rule generate_ldscore:
179178
resources:
180179
mem_mb_per_cpu=lambda wildcards, threads, attempt: 45_000 / threads * np.log2(attempt + 1),
181180
qos='huge'
182-
shell:
183-
"""
184-
GPS run_generate_ldscore --sample_name {wildcards.sample_name} --chrom {wildcards.chrom} --ldscore_save_dir {params.ld_score_save_dir} --gtf_annotation_file {params.gtf_annotation_file} --mkscore_feather_file {input.mkscore_feather_file} --bfile_root {params.bfile_root} --keep_snp_root {params.keep_snp_root} --window_size {params.window_size} --spots_per_chunk {params.spots_per_chunk} --ld_wind {params.ld_wind} --ld_unit {params.ld_unit}
185-
touch {output.done}
181+
run:
182+
command = f"""
183+
GPS run_generate_ldscore \
184+
--sample_name {wildcards.sample_name} \
185+
--chrom {wildcards.chrom} \
186+
--ldscore_save_dir {params.ld_score_save_dir} \
187+
--mkscore_feather_file {input.mkscore_feather_file} \
188+
--bfile_root {params.bfile_root} \
189+
--keep_snp_root {params.keep_snp_root} \
190+
--gtf_annotation_file {params.gtf_annotation_file} \
191+
--gene_window_size {params.gene_window_size} \
192+
{'--enhancer_annotation_file ' + params.enhancer_annotation_file if params.enhancer_annotation_file is not None else ''} \
193+
--snp_multiple_enhancer_strategy {params.snp_multiple_enhancer_strategy} \
194+
{'--gene_window_enhancer_priority ' + params.gene_window_enhancer_priority if params.gene_window_enhancer_priority is not None else ''} \
195+
--spots_per_chunk {params.spots_per_chunk} \
196+
--ld_wind {params.ld_wind} \
197+
--ld_unit {params.ld_unit}
186198
"""
199+
shell(command)
187200

188201

189202
def get_h2_file(wildcards):
@@ -210,7 +223,7 @@ rule spatial_ldsc:
210223
ldscore_input_dir=rules.generate_ldscore.params.ld_score_save_dir,
211224
ldsc_save_dir='{sample_name}/spatial_ldsc',
212225
w_file="/storage/yangjianLab/sharedata/LDSC_resource/LDSC_SEG_ldscores/weights_hm3_no_hla/weights.",
213-
sumstats_config_file='/storage/yangjianLab/chenwenhao/projects/202312_GPS/src/GPS/example/sumstats_config.yaml',
226+
sumstats_config_file='/storage/yangjianLab/chenwenhao/projects/202312_GPS/src/GPS/example/sumstats_config_sub.yaml',
214227
all_chunk = None
215228
threads:
216229
2

0 commit comments

Comments
 (0)