xinhe-lab / ctwas

package for the causal TWAS project
https://xinhe-lab.github.io/ctwas/
MIT License
32 stars 12 forks source link

Running genome-wide cTWAS with "ld_pgenfs=" option #16

Closed dhlee1013 closed 5 months ago

dhlee1013 commented 5 months ago

Hello,

I have been attempting to perform cTWAS based on “Running cTWAS genome-wide” section of cTWAS tutorial page and encountered an error that I am having difficulty resolving.

I successfully ran “Imputing gene z-scores” section with “ld_pgenfs =” option in “impute_expr_z” function using the 1000G LD reference PLINK format files provided in TWAS/FUSION website (https://data.broadinstitute.org/alkesgroup/FUSION/LDREF.tar.bz2) using the codes below:

res <- impute_expr_z(z_snp = z_snp_all, weight = my_fusion_weights, ld_pgenfs = sorted_gusev_ldref_bed, outputdir = outputdir, outname = outname, harmonize_z = T, harmonize_wgt = T, strand_ambig_action_z = "none", recover_strand_ambig_wgt = T)

However, when I tried to perform “ctwas_rss” function, the code attached below stopped at Susie iteration 1, with the following error message:

thin <- 0.1 max_snp_region <- 20000 ncore <- 6

ctwas_rss(z_gene = z_gene, z_snp = z_snp, ld_exprvarfs = ld_exprvarfs, ld_pgenfs = sorted_gusev_ldref_bed, ld_R_dir = NULL, ld_regions = "EUR", ld_regions_version = "b37", outputdir = outputdir, outname = outname, thin = thin, max_snp_region = max_snp_region, ncore = ncore)

-------error code------- 2024-03-22 00:36:38 INFO::Run susie iteratively, getting rough estimate ... 2024-03-22 00:36:38 INFO::run iteration 1 starting worker pid=315008 on localhost:11154 at 00:36:39.033 starting worker pid=315007 on localhost:11154 at 00:36:39.036 starting worker pid=315011 on localhost:11154 at 00:36:39.038 starting worker pid=315009 on localhost:11154 at 00:36:39.039 starting worker pid=315010 on localhost:11154 at 00:36:39.105 starting worker pid=315012 on localhost:11154 at 00:36:39.117 Loading required package: ctwas Loading required package: ctwas loaded ctwas and set parent environment Loading required package: ctwas loaded ctwas and set parent environment Loading required package: ctwas loaded ctwas and set parent environment Loading required package: ctwas loaded ctwas and set parent environment Loading required package: ctwas loaded ctwas and set parent environment loaded ctwas and set parent environment Error in { : task 1 failed - "input= must be a single character string containing a file name, a system command containing at least one space, a URL starting 'http[s]://', 'ftp[s]://' or 'file://', or, the input data itself containing at least one \n or \r"

I would be grateful if you could provide me with guidance or insights into potential sources of the error. Thank you!

Dong Heon

sq-96 commented 5 months ago

@dhlee1013 Hi Dong Heon,

We have updated the package a little bit. Could you try running the impute_expr_z function again. And it will write out .expervar and .expr.gz files. These .expr.gz files will be used if your LD data is from the plink format. Then the input to ctwas_rss will be:

ld_exprvarfs <- paste0(outputdir, outname, "_chr", 1:22, ".exprvar") ld_exprfs <- paste0(outputdir, outname, "_chr", 1:22, ".expr.gz")

ctwas_rss(z_gene = z_gene, z_snp = z_snp, ld_exprvarfs = ld_exprvarfs, ld_exprfs = ld_exprfs, ld_pgenfs = sorted_gusev_ldref_bed, ld_R_dir = NULL, ld_regions = "EUR", ld_regions_version = "b37", outputdir = outputdir, outname = outname, thin = thin, max_snp_region = max_snp_region, ncore = ncore)

Let me know if it solves your problems.

Best, Sheng

dhlee1013 commented 5 months ago

The new code you provided solved my problems. Thank you!

Best, Dong Heon