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
# Actually perform the differential expression analysis | |
library(yarn) | |
library(dplyr) | |
library(readr) | |
library(biomaRt) | |
library(limma) | |
source("voomweights.R") | |
obj <- readRDS("~/Desktop/gtex_v6p_lung_blood_norm.rds") | |
gender = pData(obj)$GENDER | |
batch = factor(as.character(pData(obj)$SMNABTCHT)) |
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
downloadNotInstalled<-function(x){ | |
for(i in x){ | |
if(!require(i,character.only=TRUE)){ | |
if (!requireNamespace("BiocManager")){install.packages("BiocManager")} | |
BiocManager::install(i) | |
} | |
} | |
} | |
requiredPackages = c("Biobase", "S4Vectors","SummarizedExperiment","devtools","edgeR") | |
downloadNotInstalled(requiredPackages) |
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
stratified <- function(df, group, size, select = NULL, | |
replace = FALSE, bothSets = FALSE) { | |
if (is.null(select)) { | |
df <- df | |
} else { | |
if (is.null(names(select))) stop("'select' must be a named list") | |
if (!all(names(select) %in% names(df))) | |
stop("Please verify your 'select' argument") | |
temp <- sapply(names(select), | |
function(x) df[[x]] %in% select[[x]]) |
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
library(mgcv) | |
#library(modules) #devtools::install_github(klmr/modules) | |
#mgcv<-import_package("mgcv") | |
mspline<-function(x,y,k=10,lower=NA,upper=NA){ | |
#fits a monotonic spline to data | |
#small values of k= more smoothing (flatter curves) | |
#large values of k= more flexible (wiggly curves) | |
#k is related to effective degrees of freedom and number of knots | |
#use unconstrained gam to get rough parameter estimates |
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
########################### | |
# Load Required Libraries # | |
########################### | |
library(vegan) # TSS Normalization | |
library(data.table) # fread | |
# Install MetagenomeSeq (EM_ZIG Model) | |
library(devtools) | |
# install_github('HCBravoLab/metagenomeSeq', ref='per_feature_em') | |
library(metagenomeSeq) #FIT-ZIG |
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
--- | |
title: "Beginner R Workshop" | |
output: html_document | |
date: October 27, 2016 | |
author: Keegan Korthauer and Joseph N. Paulson | |
--- | |
Today's workshop will be a gentle introduction to the | |
[R programming language](https://cran.r-project.org/). We have provided RStudio Server instances that you can access on the web, but we'll also briefly overview how you can install R and RStudio on your own computer. We'll start with some basics about programming and then get some hands-on experience with analyzing a real-world messy dataset that we'll collect from everyone live. We hope that you'll get a feel for what R can do as well as learn where you can learn more to use it on your own (great resources are listed at the end). |
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
library(yarn) | |
library(dplyr) | |
library(rafalib) | |
obj = downloadGTEx() | |
lowSampleSizes = c("Bladder","Cells - Leukemia cell line (CML)","Cervix - Ectocervix","Cervix - Endocervix","Fallopian Tube") | |
obj = filterSamples(obj,lowSampleSizes,"SMTSD") %>% | |
filterMissingGenes |
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
--- | |
title: "Shiny App" | |
author: "jpaulson" | |
output: html_document | |
runtime: shiny | |
--- | |
This R Markdown document is made interactive using Shiny and allows you to explore an eSet object. | |
# Examples |
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
extractMR<-function(obj){ | |
mat = MRcounts(obj) | |
ls = as.vector(libSize(obj)) | |
norm= as.vector(normFactors(obj)) | |
pd = pData(obj) | |
fd = fData(obj) | |
dat = list(counts=mat,librarySize=ls,normFactors=norm,pheno=pd,feat=fd) | |
return(dat) | |
} |
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
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list' | |
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9 | |
gpg -a --export E084DAB9 | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get -y install r-base libapparmor1 libcurl4-gnutls-dev libxml2-dev libssl-dev gdebi-core | |
sudo su - -c "R -e \"install.packages('shiny', repos = 'http://cran.rstudio.com/')\"" | |
sudo su - -c "R -e \"install.packages('devtools', repos='http://cran.rstudio.com/')\"" | |
sudo su - -c "R -e \"devtools::install_github('daattali/shinyjs')\"" | |
sudo su - -c "R -e \"devtools::install_github('bioc/shinyjs')\"" |
NewerOlder