Skip to content

Commit 33a6c94

Browse files
committed
spatial_ldsc_multiple_sumstats.py fix the y inplace error
1 parent 494a96b commit 33a6c94

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/GPS/spatial_ldsc_multiple_sumstats.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def run_spatial_ldsc(config: SpatialLDSCConfig):
128128

129129
filter_by_common_snp = lambda df: df.loc[common_snp]
130130
sumstats = filter_by_common_snp(sumstats)
131+
CHISQ = sumstats.chisq.to_numpy(dtype=np.float32).reshape((-1, 1)).copy()
131132
ref_ld_baseline = filter_by_common_snp(ref_ld_baseline)
132133
w_ld = filter_by_common_snp(w_ld)
133134
n_annot_baseline = len(ref_ld_baseline.columns)
@@ -178,8 +179,7 @@ def run_spatial_ldsc(config: SpatialLDSCConfig):
178179
ref_ld_spatial *= initial_w
179180
ref_ld_spatial = ref_ld_spatial.to_numpy(dtype=np.float32)
180181

181-
y = sumstats.chisq.to_numpy(dtype=np.float32).reshape((-1, 1))
182-
y *= initial_w
182+
y = CHISQ * initial_w
183183

184184
chunk_size = ref_ld_spatial.shape[1]
185185
out_chunk = process_map(jackknife_for_processmap, range(chunk_size),
@@ -234,5 +234,19 @@ def run_spatial_ldsc(config: SpatialLDSCConfig):
234234
args = parser.parse_args(args_list)
235235
else:
236236
args = parser.parse_args()
237-
config = SpatialLDSCConfig(**vars(args))
237+
import os
238+
239+
os.chdir('/storage/yangjianLab/chenwenhao/projects/202312_GPS/data/macaque/representative_slices2')
240+
config = SpatialLDSCConfig(**{'all_chunk': None,
241+
'chisq_max': None,
242+
'h2': '/storage/yangjianLab/songliyang/GWAS_trait/LDSC/ADULT1_ADULT2_ONSET_ASTHMA.sumstats.gz',
243+
'ldsc_save_dir': 'T135_macaque1/spatial_ldsc',
244+
'ldscore_input_dir': 'T135_macaque1/generate_ldscore',
245+
'n_blocks': 200,
246+
'not_M_5_50': False,
247+
'num_processes': 4,
248+
'sample_name': 'T135_macaque1',
249+
'trait_name': 'ADULT1_ADULT2_ONSET_ASTHMA',
250+
'w_file': '/storage/yangjianLab/sharedata/LDSC_resource/LDSC_SEG_ldscores/weights_hm3_no_hla/weights.'})
251+
# config = SpatialLDSCConfig(**vars(args))
238252
run_spatial_ldsc(config)

0 commit comments

Comments
 (0)