Last updated: 2020-08-20

Checks: 6 1

Knit directory: SlopeHunter/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20200723) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 61b51b2. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    R/.Rhistory

Unstaged changes:
    Modified:   analysis/tutorial.Rmd

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/tutorial.Rmd) and HTML (docs/tutorial.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 3d9bce3 Osama 2020-08-20 Update tutorial on website - still ongoing
html 3d9bce3 Osama 2020-08-20 Update tutorial on website - still ongoing

Simulated Data

Report tutorials on the simulated data here …

Applied Data Analysis

Example: Fasting Insulin adjusted for BMI

Install Slope-Hunter

Follow the installation instructions described here.

Format Data for Slope-Hunter Analysis

First, you need to load the Slope-Hunter R package:

library(SlopeHunter)
API: public: http://gwas-api.mrcieu.ac.uk/

    ______                        __   __
   / ____/__    ____  _________  / /  / /_  ____   __________________
  / /__  / /   / _  \/ _  / __/ / /__/ / / / / \  / /_  __/ ___/ _  /
  \___ \/ /   / / / / ___/ /_  /  __  / / / / / \/ / / / / /_ /   _/
 ____/ / /___/ /_/ / /  / /_  / /  / / /_/ / /  \ / / / / /__/ / \
/_____/\____/\____/_/  /___/ /_/  /_/\____/_/  \_/ /_/ /____/_/ \_\  version
Package 'SlopeHunter' version 0.0.1

Read in the incidence (the condition trait) data

BMI_incidence <- read_incidence(filename = "Your-incidence-data-file.gz",
  gz = TRUE,
  eaf_col="Freq_Tested_Allele_in_HRS",
  effect_allele_col="Tested_Allele",
  other_allele_col="Other_Allele",
  pval_col = "P",
  pos_col = "POS")

Read in the conditional outcome data (BMI-adjusted Insulin)

Insulin_adj_BMI <- read_prognosis("Your-conditional-outcome-data-file.txt", 
                                  gz = FALSE,
                                  sep = "\t",
                                  snp_col = "ID",
                                  beta_col = "BETA",
                                  se_col = "SE",
                                  pval_col = "P",
                                  effect_allele_col = "EA",
                                  other_allele_col = "NEA",
                                  chr_col = "Chromosome",
                                  pos_col = "Position")

Harmonisation

Data_harmonised <- harmonise_effects(incidence_dat = BMI_incidence,
                                prognosis_dat = Insulin_adj_BMI,
                                by.pos = TRUE, pos_cols = c("POS.incidence", "POS.prognosis"),
                                snp_cols=c("SNP", "SNP"),
                                beta_cols = c("BETA.incidence", "BETA.prognosis"),
                                se_cols=c("SE.incidence", "SE.prognosis"),
                                EA_cols=c("EA.incidence", "EA.prognosis"),
                                OA_cols=c("OA.incidence", "OA.prognosis")
                                )
nrow(Data_harmonised)               # No. SNPs present in both datasets
attributes(Data_harmonised)$info    # Get info on the harmonisation process

Extract valid data after harmonisation (those that are eligible for pruning)

Data_to_prune <- Data_harmonised[!Data_harmonised$remove, ]
nrow(Data_to_prune)                 # No. SNPs to be pruned

Pruning data

Data_pruned <- LD_prune(Data_to_prune, Random = TRUE, seed = 15151515)

Apply the Slope-Hunter approach

TBA …


sessionInfo()