MRCIEU / TwoSampleMR

R package for performing 2-sample MR using MR-Base database
https://mrcieu.github.io/TwoSampleMR
Other
418 stars 176 forks source link

mv_extract_exposures_local exposure.pval #235

Open Reavyr opened 3 years ago

Reavyr commented 3 years ago

Hi,

I've tried running mv_extract_exposures_local() like this:

filenames_exposure=c("leadSNPs_Exposure1.txt","leadSNPs_Exposure2.txt") exposure_dat<-mv_extract_exposures_local(filenames_exposure,sep="\t",snp_col="SNP", beta_col="beta", se_col="se",effect_allele_col = "alt",other_allele_col = "ref",pval_col ="pval",min_pval = 1e-200,log_pval = FALSE,pval_threshold = 5e-08,clump_r2 = 0.001,clump_kb = 10000,harmonise_strictness = 2) WARNING: Experimental function No phenotype name specified, defaulting to 'outcome'. Error in eval(e, x, parent.frame()) : object 'pval.exposure' not found In addition: Warning messages: 1: In format_data(as.data.frame(outcome_dat), type = "outcome", snps = snps, : The following columns are not present but are helpful for harmonisation eaf

2: In format_data(outcome_dat, beta_col = "beta.outcome", se_col = "se.outcome", : eaf column is not numeric. Coercing...

It seems to try to read in the data as outcome, when it should be exposure data? what could be the reason? I clearly have a pvalue column in both files.

senkkon commented 3 years ago

Hi, I have the same issue. Any updates about it?

Thank you.

albert-ying commented 3 years ago

Same issue here.

mvab commented 3 years ago

this error: object 'pval.exposure' not found arises because here https://github.com/MRCIEU/TwoSampleMR/blob/master/R/multivariable_mr.R#L114

l_inst[[i]] <- subset(l_full[[i]], pval.exposure < pval_threshold)

it is trying to subset l_full object, but it's in .outcome format, so 'pval.exposure' column does not exist.

To fix this, need to replace l_full with l_inst on this line