MRCIEU / TwoSampleMR

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

"Error in data.frame(…, check.names = FALSE) : arguments imply differing number of rows: 1, 0." during harmonisation. #293

Open Margo-bel opened 3 years ago

Margo-bel commented 3 years ago

Hello everyone. I am trying to perform Mandalian Randomisation using R package “TwoSampleMR”. As a exposure data I use instruments from GWAS catalog. (Phenotype - Sphingolipid levels). As a outcome data I use GISCOME ischemic stroke outcome GWAS (http://www.kp4cd.org/index.php/node/391) I have an error when I do harmonisation by the command harmonise_data(). The text of error is: Error in data.frame(…, check.names = FALSE) : arguments imply differing number of rows: 1, 0. I have noticed that the error is caused by some exact lines in the file with outcomes. When I make a text file that contains only one line from original file and use it like an outcome data, some lines cause an error, and some ones don’t. As an example this one causes an error:

MarkerName CHR POS Allele1 Allele2 Freq1 Effect StdErr P-value rs10938494 4 47563448 a g 0.2139 0.0294 0.0519 0.5706

This one doesn’t:

rs1000778 11 61655305 a g 0.2559 0.0939 0.0493 0.05705

Here is all commands that I use. library(TwoSampleMR) library(MRInstruments) data(gwas_catalog) exp <- subset(gwas_catalog, grepl("Sphingolipid levels", Phenotype)) exp_dat<-format_data(exp) exp_dat<-clump_data(exp_dat) exp_dat out_dat<-read_outcome_data( snps=exp_dat$SNP, filename='giscome.012vs3456.age-gender-5PC.meta1.txt' sep='\t', snp_col='MarkerName', beta_col='Effect', se_col='StdErr', effect_allele_col='Allele1', other_allele_col='Allele2', eaf_col='Freq1', pval_col='Р-value' ) dat<-harmonise_data(exposure_dat=exp_dat, outcome_dat=out_dat)

What would be the reason of this problem? Thank you.

jessica-lundin commented 2 years ago

Hello, I am having the same issue. Did you ever get this resolved? Many thanks in advance for your help.

Jessica

basilmars commented 1 year ago

Hello,

I got the same issue, too. Is there any solution?

Any help is acknowledged.

TrStans606 commented 11 months ago

I get the same issue running:

library(TwoSampleMR) library(MRInstruments) data(package = “MRInstruments”) data(gwas_catalog) subset(gwas_catalog, Phenotype == "Body mass index) exposure_dat <- subset(gwas_catalog, Phenotype == "Type 2 diabetes") d2_exp_dat <- format_data(exposure_dat) outcome_dat <- extract_outcome_data(snps=exposure_dat$SNP, outcomes = "ieu-a-815") dat <- harmonise_data(d2_exp_dat, outcome_dat)

DesmondCampbell commented 11 months ago

The code below, that failed for you, worked for me (after fixing some " typos). ...Removing the following SNPs for being palindromic with intermediate allele frequencies:rs6066138, rs622217, rs6795735, rs7572970, rs7612463, rs7674212, rs7841082

dim(dat)[1] 122  42 sessionInfo()R version 4.3.1 (2023-06-16 ucrt)Platform: x86_64-w64-mingw32/x64 (64-bit)Running under: Windows 10 x64 (build 19045) Matrix products: default

locale:[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8    LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C                           [5] LC_TIME=English_United Kingdom.utf8     time zone: Europe/Londontzcode source: internal attached base packages:[1] stats     graphics  grDevices utils     datasets  methods   base      other attached packages:[1] MRInstruments_0.3.2 TwoSampleMR_0.5.7   loaded via a namespace (and not attached): [1] utf8_1.2.3       R6_2.5.1         tidyselect_1.2.0 magrittr_2.0.3   glue_1.6.2       tibble_3.2.1     ieugwasr_0.1.5   pkgconfig_2.0.3  dplyr_1.1.2     [10] generics_0.1.3   lifecycle_1.0.3  cli_3.6.1        fansi_1.0.4      vctrs_0.6.3      compiler_4.3.1   httr_1.4.7       plyr_1.8.8       tools_4.3.1     [19] curl_5.0.2       pillar_1.9.0     Rcpp_1.0.11      jsonlite_1.8.7   rlang_1.1.1     >  Desmond

On Sunday, 29 October 2023 at 05:00:45 GMT, TrStans606 ***@***.***> wrote:  

I get the same issue running:

library(TwoSampleMR) library(MRInstruments) data(package = “MRInstruments”) data(gwas_catalog) subset(gwas_catalog, Phenotype == "Body mass index) exposure_dat <- subset(gwas_catalog, Phenotype == "Type 2 diabetes") d2_exp_dat <- format_data(exposure_dat) outcome_dat <- extract_outcome_data(snps=exposure_dat$SNP, outcomes = "ieu-a-815") dat <- harmonise_data(d2_exp_dat, outcome_dat)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

TrStans606 commented 11 months ago

I get the same issue running:

library(TwoSampleMR) library(MRInstruments) exposure_dat <- subset(gwas_catalog, Phenotype == "Age of smoking initiation") d2_exp_dat <- format_data(exposure_dat) outcome_dat <- extract_outcome_data(snps=exposure_dat$SNP, outcomes = "ieu-a-815") dat <- harmonise_data(d2_exp_dat, outcome_dat)

Seems to be an issue with specific IVs from the MRInstruments package

joandogo commented 7 months ago

The code below, that failed for you, worked for me (after fixing some " typos). ...Removing the following SNPs for being palindromic with intermediate allele frequencies:rs6066138, rs622217, rs6795735, rs7572970, rs7612463, rs7674212, rs7841082 dim(dat)[1] 122  42 sessionInfo()R version 4.3.1 (2023-06-16 ucrt)Platform: x86_64-w64-mingw32/x64 (64-bit)Running under: Windows 10 x64 (build 19045) Matrix products: default locale:[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8    LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C                           [5] LC_TIME=English_United Kingdom.utf8     time zone: Europe/Londontzcode source: internal attached base packages:[1] stats     graphics  grDevices utils     datasets  methods   base      other attached packages:[1] MRInstruments_0.3.2 TwoSampleMR_0.5.7   loaded via a namespace (and not attached): [1] utf8_1.2.3       R6_2.5.1         tidyselect_1.2.0 magrittr_2.0.3   glue_1.6.2       tibble_3.2.1     ieugwasr_0.1.5   pkgconfig_2.0.3  dplyr_1.1.2     [10] generics_0.1.3   lifecycle_1.0.3  cli_3.6.1        fansi_1.0.4      vctrs_0.6.3      compiler_4.3.1   httr_1.4.7       plyr_1.8.8       tools_4.3.1     [19] curl_5.0.2       pillar_1.9.0     Rcpp_1.0.11      jsonlite_1.8.7   rlang_1.1.1     >  Desmond On Sunday, 29 October 2023 at 05:00:45 GMT, TrStans606 @.> wrote: I get the same issue running: library(TwoSampleMR) library(MRInstruments) data(package = “MRInstruments”) data(gwas_catalog) subset(gwas_catalog, Phenotype == "Body mass index) exposure_dat <- subset(gwas_catalog, Phenotype == "Type 2 diabetes") d2_exp_dat <- format_data(exposure_dat) outcome_dat <- extract_outcome_data(snps=exposure_dat$SNP, outcomes = "ieu-a-815") dat <- harmonise_data(d2_exp_dat, outcome_dat) — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.>

Hi @DesmondCampbell,

Could you explain to us how you identified the typographical errors and eliminated the palindromes, was this done from the display or from the output? I'd appreciate it