Created
December 2, 2022 21:09
-
-
Save allanjust/e0b3887f9fcb5bfeac6879fd2770e979 to your computer and use it in GitHub Desktop.
Estimate cell composition in a public 450k sample using ewastools and the HRS coefficients
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# demo using the ewastools package to estimate leukocyte composition from a public 450k sample | |
# using results learned from HRS (see preprint https://www.biorxiv.org/content/10.1101/2022.11.28.518190v1.full) | |
if("ewastools" %in% rownames(installed.packages()) == FALSE){ | |
install.packages("BiocManager") | |
BiocManager::install("illuminaio") | |
remotes::install_github("hhhh5/ewastools") # at least v1.7.1 | |
} | |
library(ewastools) | |
library(here) | |
library(R.utils) | |
# from https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=%20GSE87571 | |
# grab idat files for first sample "X1 genomic DNA from whole blood" | |
filename <- "GSM2333901_9370847096_R05C02" | |
fileurlGrn <- "https://www.ncbi.nlm.nih.gov/geo/download/?acc=GSM2333901&format=file&file=GSM2333901%5F9370847096%5FR05C02%5FGrn%2Eidat%2Egz" | |
fileurlRed <- "https://www.ncbi.nlm.nih.gov/geo/download/?acc=GSM2333901&format=file&file=GSM2333901%5F9370847096%5FR05C02%5FRed%2Eidat%2Egz" | |
download.file(fileurlGrn, destfile = here(paste0(filename, "_Grn.idat.gz"))) | |
download.file(fileurlRed, destfile = here(paste0(filename, "_Red.idat.gz"))) | |
gunzip(paste0(filename, "_Grn.idat.gz")) | |
gunzip(paste0(filename, "_Red.idat.gz")) | |
# import and preprocess this sample | |
meth = | |
filename |> | |
read_idats(quiet=FALSE) |> | |
detectionP() |> | |
correct_dye_bias() |> | |
mask(0.05) | |
meth = dont_normalize(meth) # matrix of beta values | |
print(estimateLC(meth, ref = "HRS"), digits = 2) | |
# and for reference, here is a Houseman approach using Reinius as the reference dataset | |
print(estimateLC(meth, ref = "Reinius"), digits = 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment