n-mounier / MRlap

R package to perform two-sample Mendelian Randomisation (MR) analyses using (potentially) overlapping samples
GNU General Public License v2.0
49 stars 11 forks source link

Two new options: allow local LD clumping, or user can provide list of IVs (and no pruning performed) #10

Closed lcpilling closed 11 months ago

lcpilling commented 1 year ago

Hi Ninon,

With these changes, the user can:

These three examples show the changes in syntax/options (the first is the normal behaviour of v0.3.0 with remote clumping):

# determine IVs using TwoSampleMR::clump_data() with R^2=0.001 (remote clumping)
test1 = MRlap::MRlap(exposure = gwas_exp, exposure_name = "exposure_gwas",
                     outcome = gwas_out, outcome_name = "outcome_gwas",
                     ld = ld_dir, hm3 = hm3_file,
                     MR_pruning_LD=0.001)

# use ieugwasr::ld_clump() and local Plink installation with custom panel for clumping with R^2=0.001
test2 = MRlap::MRlap(exposure = gwas_exp, exposure_name = "exposure_gwas",
                     outcome = gwas_out, outcome_name = "outcome_gwas",
                     ld = ld_dir, hm3 = hm3_file,
                     MR_pruning_LD=0.001,
                     MR_plink = "plink",
                     MR_bfile = "/path/to/ukbiobank/imputed_500k/5k_eur/ukb_imp_v3.5k_eur")

# do not perform clumping. User-provided list of variant IDs instead 
test3 = MRlap::MRlap(exposure = gwas_exp, exposure_name = "exposure_gwas",
                     outcome = gwas_out, outcome_name = "outcome_gwas",
                     ld = ld_dir, hm3 = hm3_file,
                     do_pruning = FALSE,
                     user_SNPsToKeep = c("rs11121214", "rs3917932", "rs776431379", "rs6686289", ...))

I have put a few minor checks of the input but I guess ideally there would be "better" checking (e.g., that provided IDs are in the data - I just assume the user has checked this, or that the Plink binary actually exists).

Feel free to make changes, of course, and no problem if you don't want to implement. I had made these changes for a project so thought I'd put them back on GitHub in case useful to others.

Luke

zkutalik commented 1 year ago

Thanks so much, Luke, for your help to improve MRlap!

Zoltan

On Tue, 3 Oct 2023 at 15:09, Luke C. Pilling @.***> wrote:

Hi Ninon,

With these changes, the user can:

  • use local installation of Plink for LD clumping with a custom reference panel (using MR_plink and MR_bfile options). This is useful to e.g., use a subset of UK Biobank EUR as reference panel
  • turn off automatic pruning and instead provide own list of variants to use as Instrumental Variables (using do_pruning and user_SNPsToKeep options)

These three examples (#1 https://github.com/n-mounier/MRlap/pull/1 is the normal behaviour of v0.3.0 with remote clumping) to demonstrate the syntax/options.

determine IVs using TwoSampleMR::clump_data() with R^2=0.001 (remote clumping)test1 = MRlap::MRlap(exposure = gwas_exp, exposure_name = "exposure_gwas",

                 outcome = gwas_out, outcome_name = "outcome_gwas",
                 ld = ld_dir, hm3 = hm3_file,
                 MR_pruning_LD=0.001)

use ieugwasr::ld_clump() and local Plink installation with custom panel for clumping with R^2=0.001test2 = MRlap::MRlap(exposure = gwas_exp, exposure_name = "exposure_gwas",

                 outcome = gwas_out, outcome_name = "outcome_gwas",
                 ld = ld_dir, hm3 = hm3_file,
                 MR_pruning_LD=0.001,
                 MR_plink = "plink",
                 MR_bfile = "/path/to/ukbiobank/imputed_500k/5k_eur/ukb_imp_v3.5k_eur")

do not perform clumping. User-provided list of variant IDs instead test3 = MRlap::MRlap(exposure = gwas_exp, exposure_name = "exposure_gwas",

                 outcome = gwas_out, outcome_name = "outcome_gwas",
                 ld = ld_dir, hm3 = hm3_file,
                 do_pruning = FALSE,
                 user_SNPsToKeep = c("rs11121214", "rs3917932", "rs776431379", "rs6686289", ...))

I have put a few minor checks of the input but I guess ideally there would be "better" checking (e.g., that provided IDs are in the data - I just assume the user has checked this, or that the Plink binary actually exists).

Feel free to make changes, of course, and no problem if you don't want to implement. I had made these changes for a project so thought I'd put them back on GitHub in case useful to others.

Luke

You can view, comment on, or merge this pull request online at:

https://github.com/n-mounier/MRlap/pull/10 Commit Summary

File Changes

(7 files https://github.com/n-mounier/MRlap/pull/10/files)

Patch Links:

— Reply to this email directly, view it on GitHub https://github.com/n-mounier/MRlap/pull/10, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADUPFNIXIPU24ZM5AA52AXTX5QE75AVCNFSM6AAAAAA5Q66N5SVHI2DSMVQWIX3LMV43ASLTON2WKOZRHEZDIMJSGAYDSOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>