Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to construct your own exposure and outcome datasets? #286

Closed
mocksu opened this issue Jul 22, 2021 · 1 comment
Closed

How to construct your own exposure and outcome datasets? #286

mocksu opened this issue Jul 22, 2021 · 1 comment

Comments

@mocksu
Copy link

mocksu commented Jul 22, 2021

Suppose you have your own exposure GWAS and your own outcome GWAS, how can you do a 2 sample MR?

@remlapmot
Copy link
Contributor

remlapmot commented Jul 26, 2021

You can do this.

You need to put your exposure and outcome data into data.frames with the relevant column names. See the example below for the names or there is a little example here.

library(TwoSampleMR)
#> TwoSampleMR version 0.5.6 
#> [>] New: Option to use non-European LD reference panels for clumping etc
#> [>] Some studies temporarily quarantined to verify effect allele
#> [>] See news(package='TwoSampleMR') and https://gwas.mrcieu.ac.uk for further details
ao <- available_outcomes()
#> API: public: http://gwas-api.mrcieu.ac.uk/
#> API: public: http://gwas-api.mrcieu.ac.uk/
bmi_exp_dat <- extract_instruments(outcomes='ieu-a-2')
chd_out_dat <- extract_outcome_data(snps = bmi_exp_dat$SNP, outcomes = 'ieu-a-7')
#> Extracting data for 79 SNP(s) from 1 GWAS(s)
#> Extracting data for 79 SNP(s) from 1 GWAS(s)

class(bmi_exp_dat)
#> [1] "data.frame"
names(bmi_exp_dat)
#>  [1] "pval.exposure"          "samplesize.exposure"    "chr.exposure"          
#>  [4] "se.exposure"            "beta.exposure"          "pos.exposure"          
#>  [7] "id.exposure"            "SNP"                    "effect_allele.exposure"
#> [10] "other_allele.exposure"  "eaf.exposure"           "exposure"              
#> [13] "mr_keep.exposure"       "pval_origin.exposure"   "data_source.exposure"

class(chd_out_dat)
#> [1] "data.frame"
names(chd_out_dat)
#>  [1] "SNP"                   "chr"                   "pos"                  
#>  [4] "beta.outcome"          "se.outcome"            "samplesize.outcome"   
#>  [7] "pval.outcome"          "eaf.outcome"           "effect_allele.outcome"
#> [10] "other_allele.outcome"  "outcome"               "id.outcome"           
#> [13] "originalname.outcome"  "outcome.deprecated"    "mr_keep.outcome"      
#> [16] "data_source.outcome"

Created on 2021-07-26 by the reprex package (v2.0.0)

You should then be able to run harmonise_data() on your data.frames as per our examples, e.g. here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants