This file contains hidden or 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
# Use this library - it handles linear regression instead of assuming balanced ANOVA | |
library(pwr) | |
# Just gonna simulate some data but you can obviously use the actual allele frequencies, effect sizes and phenotypic variances | |
# Allele frequencies: | |
nsnp <- 29 | |
p <- runif(nsnp) |
This file contains hidden or 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
n <- 1000 | |
# cor_g and cor_e both positive | |
g <- rnorm(n) | |
e <- rnorm(n) * 0.5 | |
g1 <- g + rnorm(n) | |
g2 <- g + rnorm(n) | |
cor(g1,g2) | |
e1 <- e + rnorm(n) | |
e2 <- e + rnorm(n) |
This file contains hidden or 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
a <- read.table("~/Desktop/analysis1_allstudies.txt", he=T, sep="\t") | |
b <- subset(a, outcome %in% c("cardiogram", "bladdercancer")) | |
tel <- subset(b, select=c(snp.exposure, allele1, allele2, effect.exposure, se.exposure, chr_name, chr_pos, outcome, effect_allele, other_allele, beta.outcome, se.outcome, eaf.outcome, eaf.trait)) | |
names(tel) <- c("SNP", "effect_allele.exposure", "other_allele.exposure", "beta.exposure", "se.exposure", "chr_name", "chrom_start", "outcome", "effect_allele.outcome", "other_allele.outcome", "beta.outcome", "se.outcome", "eaf.outcome", "eaf.exposure") | |
tel$exposure <- "Telomere length" | |
card <- subset(tel, outcome=="cardiogram", select=c(SNP, effect_allele.outcome, other_allele.outcome, beta.outcome, se.outcome, eaf.outcome)) | |
names(card) <- c("SNP", "effect_allele", "other_allele", "beta", "se", "eaf") |
This file contains hidden or 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
Phenotype SNP effect_allele other_allele beta se eaf samplesize units | |
Telomere_length rs4452212 G A 0.048547045 0.025368957 0.384488126 20000 mg | |
Telomere_length rs621559 G A 0.003061092 0.019672991 0.930963777 20000 mg | |
Telomere_length rs755017 G A 0.012278742 0.012858208 0.135563686 20000 mg | |
Telomere_length rs7675998 G A 0.030833397 0.018161069 0.774290377 20000 mg | |
Telomere_length rs8105767 G A 0.041388996 0.011055945 0.290208018 20000 mg | |
Telomere_length rs10936599 C T 0.064543244 0.016425136 0.764278349 20000 mg | |
Telomere_length rs10936601 C T 0.056461006 0.010547034 0.743640342 20000 mg | |
Telomere_length rs2736100 C A 0.055542945 0.013068791 0.51724734 20000 mg | |
Telomere_length rs3027234 C T 0.065856682 0.014545151 0.77323311 20000 mg |
This file contains hidden or 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
shinyApp( | |
ui = navbarPage(title="test", id="mainNavbarPage", | |
tabPanel("Input", value="tabinput", | |
numericInput('n', 'Number of obs', 100), | |
actionButton(inputId="submit_button", label="Submit") | |
), | |
tabPanel("Output", value="taboutput", | |
verbatimTextOutput("messages"), |
This file contains hidden or 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
query= 17554300 | |
#run the search | |
search <- EUtilsSummary(query, type="esearch",db = "pubmed",retmax=30000) | |
QueryCount(search) #how many hits | |
summary(search) #number of hits and search terms used | |
records <- EUtilsGet(search) #get the results from search | |
PMID(records) | |
Author(records)[[1]] | |
a <- Mesh(records)[[1]] |
This file contains hidden or 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
query= 17554300 | |
#run the search | |
search <- EUtilsSummary(query, type="esearch",db = "pubmed",retmax=30000) | |
QueryCount(search) #how many hits | |
summary(search) #number of hits and search terms used | |
records <- EUtilsGet(search) #get the results from search | |
PMID(records) | |
Author(records)[[1]] | |
a <- Mesh(records)[[1]] |
This file contains hidden or 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
newmat <- as.data.frame(t(mat)) | |
newmat$ALN <- rownames(newmat) | |
combineddata <- merge(bmi, newmat, by="ALN") | |
# See if they are individually associated with BMI | |
model <- lm(bmi ~ cpg1) | |
This file contains hidden or 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
# Some example data | |
# Data frame with an id column | |
data1 <- data.frame(ids = c("A", "B", "C"), value = 1:3) | |
# matrix with rownames for ids | |
data2 <- matrix(1:20, 4, 5) | |
rownames(data2) <- c("C", "D", "B", "E") | |
# Get data1 into the same order as data2 |
This file contains hidden or 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
here is a gist |