library(readxl)
GC_R_test <- read_excel("Dropbox/Peebles Lab Research/SUSCHEM/GC R test.xlsx")
View(GC_R_test)
#Create Line Chart
xrange <- Hr.
hour=[-9.5
1.5
3
5
7
9
12
22
23
23.5
24
24.5
25
26
28
30
32
34
35
35.5
36
36.5
37
38
40
42
44
46
48
49]
library(readxl)
X2017_11_19_Growth_Curve_analysis_for_R <- read_excel("Dropbox/Peebles Lab Research/SUSCHEM/Growth & Cell Counts/2017_11_19 Growth Curve analysis for R.csv")
View(X2017_11_19_Growth_Curve_analysis_for_R)
library(readxl)
X2017_11_19_Growth_Curve_analysis <- read_excel("Dropbox/Peebles Lab Research/SUSCHEM/Growth & Cell Counts/2017_11_19 Growth Curve analysis.xlsx")
View(X2017_11_19_Growth_Curve_analysis)
install.packages("devtools", repos="http://cran.us.r-project.org", dependencies=TRUE)
library(devtools)
install_github("cbroeckl/RAMClustR", build_vignettes = TRUE, dependencies = TRUE)
verson
version
install.packages("~/Downloads/InterpretMSSpectrum_1.1.tar.gz", repos = NULL, type = "source")
source("http://bioconductor.org/biocLite.R")
biocLite("Rdisop")
install.packages("~/Downloads/enviPat_2.2.tar.gz", repos = NULL, type = "source")
install.packages("~/Downloads/DBI_0.7.tar.gz", repos = NULL, type = "source")
install.packages("~/Downloads/RSQLite_2.0.tar.gz", repos = NULL, type = "source")
install.packages("~/Downloads/InterpretMSSpectrum_1.1.tar.gz", repos = NULL, type = "source")
install_github("cbroeckl/RAMClustR", build_vignettes = TRUE, dependencies = TRUE)
install_github("cbroeckl/RAMClustR", build_vignettes = TRUE, dependencies = TRUE)
library(devtools)
install.packages("~/Downloads/InterpretMSSpectrum_1.1.tar.gz", repos = NULL, type = "source")
install.packages("~/Downloads/RSQLite_2.0.tar.gz", repos = NULL, type = "source")
install.packages("~/Downloads/bit64_0.9-7.tar.gz", repos = NULL, type = "source")
install.packages("~/Downloads/blob_1.1.0.tar.gz", repos = NULL, type = "source")
install.packages("~/Downloads/plogr_0.1-1.tar.gz", repos = NULL, type = "source")
install.packages("~/Downloads/RSQLite_2.0.tar.gz", repos = NULL, type = "source")
install.packages("~/Downloads/InterpretMSSpectrum_1.1.tar.gz", repos = NULL, type = "source")
install_github("cbroeckl/RAMClustR", build_vignettes = TRUE, dependencies = TRUE)
library(RAMClustR)
vignette("RAMClustR")
source("http://bioconductor.org/biocLite.R")
biocLite("xcms")
library(xcms)
library(faahKO)
source("http://bioconductor.org/biocLite.R")
biocLite("faahKO")
library(faahKO)
cdfpath <- system.file("cdf", package = "faahKO")
cdffiles <- list.files(cdfpath, recursive = TRUE, full.names = TRUE)
xset <- xcmsSet(cdffiles)  # detect features
# detect features
xset <- xcmsSet(cdiffiles)
xset <- xcmsSet(cdffiles)
xset <- group(xset)  # group features across samples by retention time and mass
xset <- retcor(xset, family = "symmetric", plottype = NULL)  # correct for drive in retention time
xset <- group(xset, bw = 10)  # regroup following rt correction
xset <- group(xset, bw = 10)  # regroup following rt correction
xset <- fillPeaks(xset)  # 'fillPeaks' to remove missing values in final dataset
xset
experiment <- defineExperiment(csv = TRUE) # experiment <- defineExperiment(force.skip = TRUE)
experiment <- defineExperiment(csv = TRUE) # experiment <- defineExperiment(force.skip = TRUE)
experiment <- defineExperiment(csv = TRUE) # experiment <- defineExperiment(force.skip = TRUE)
GCMS
GC-Ms
GC-MS
experiment <- defineExperiment(csv = TRUE) # experiment <- defineExperiment(force.skip = TRUE)
RC <- ramclustR(xcmsObj = xset, ExpDes=experiment)
write.csv(RC$SpecAbund, file="SpecAbund.csv", row.names=TRUE)
write.csv(RC$SpecAbund, file="SpecAbund.csv", row.names=TRUE)
RC <- ramclustR(xcmsObj = xset, ExpDes=experiment)
write.csv(RC$SpecAbund, file="SpecAbund.csv", row.names=TRUE)
ramclustR
experiment <- defineExperiment(csv = FALSE) # experiment <- defineExperiment(force.skip = TRUE)
RC <- ramclustR(xcmsObj = xset, ExpDes=experiment)
ramclustR
experiment <- defineExperiment(csv = FALSE) <- defineExperiment(force.skip = TRUE)
experiment <- defineExperiment(csv = TRUE) # experiment <- defineExperiment(force.skip = TRUE)
experiment <- defineExperiment(csv = TRUE) # experiment <- defineExperiment(force.skip = TRUE)
RC <- ramclustR(xcmsObj = xset, ExpDes=experiment)
write.csv(RC$SpecAbund, file="SpecAbund.csv", row.names=TRUE)
# make csv files - outcsv1 for real MS data, outcsv2 for 'fake' idMSMS data after adding some noise.
outcsv1<-RC$MSdata
outcsv2<-abs(jitter(outcsv1, factor = 0.1))
write.csv(outcsv1, file = paste0(getwd(), "/msdata.csv"), row.names = TRUE)
write.csv(outcsv2, file = paste0(getwd(), "/msmsdata.csv"), row.names = TRUE)
# run ramclustR on those csv files
# first the MS data only
RC1 <- ramclustR(ms = paste0(getwd(), "/msdata.csv"),
featdelim = "_",
st = 5,
ExpDes=experiment,
sampNameCol = 1)
RC2 <- ramclustR(ms = paste0(getwd(), "/msdata.csv")
idmsms = paste0(getwd(), "/msmsdata.csv"),
featdelim = "_",
timepos = 2,
st = 5,
ExpDes=experiment,
sampNameCol = 1)
View(xset)
View(RC)
View(xset)
View(xset)
View(RC1)
View(RC)
View(RC1)
View(RC)
View(outcsv2)
View(outcsv1)
View(experiment)
View(outcsv1)
View(experiment)
save.image("~/20171214_RAMClustR.RData")
install.packages("ggplot2")
install.packages("ggplot2")
install.packages("ggplot2")
install.packages("ggplot2")
install.packages("ggplot2")
##### Install packages
install.packages("https://github.com/xia-lab/MetaboAnalystR")
##### Install packages
ls -l /Library/Frameworks/R.framework/Versions/
install.packages("https://github.com/xia-lab/MetaboAnalystR")
##### Install packages
ls -l/Library/Frameworks/R.framework/Versions/
install.packages("https://github.com/xia-lab/MetaboAnalystR")
##### Install packages
ls(/Library/Frameworks/R.framework/Versions/)
##### Install packages
ls(Library/Frameworks/R.framework/Versions/)
ln -sfhv /Library/Frameworks/R.framework/Versions/3.0 /Library/Frameworks/R.framework/Versions/Current
ls()
?ls
##### Install packages
ls -l /Library/Frameworks/R.framework/Versions/
?ls
##### Install packages
ls -l /Library/Frameworks/R.framework/Versions/
ls(-l)
##### Install packages
ls -l /Library/Frameworks/R.framework/Versions/
ls(l)
##### Install packages
ls -l /Library/Frameworks/R.framework/Versions/
ls(Library/Frameworks/R.framework/Versions)
##### Install packages
ls -l /Library/Frameworks/R.framework/Versions/
ls(Library/Frameworks/R.framework/Versions)
##### Install packages
ls -l /Library/Frameworks/R.framework/Versions/
Library/Frameworks/R.framework/Versions
##### Install packages
ls()
##### Install packages
ls(l, Library/Frameworks/R.framework/Versions)
sessionInfo()
?version
getRversion(2.6.1)
?getRversion
?ln
??ln
ln -sfhv /Library/Frameworks/R.framework/Versions/3.0 /Library/Frameworks/R.framework/Versions/Current
ln(-sfhv, /Library/Frameworks/R.framework/Versions/3.0 /Library/Frameworks/R.framework/Versions/Current)
ln(-sfhv, Library/Frameworks/R.framework/Versions/3.0 /Library/Frameworks/R.framework/Versions/Current)
?sfhv
ls -l /Library/Frameworks/R.framework/Versions/
ls -l /Library/Frameworks/R.framework/Versions/
#####
install.packages("MetaboAnalystR")
#####
install.packages("MetaboAnalystR")
install.packages("https://cran-archive.r-project.org/bin/macosx/2.1/")
version
install.packages("MetaboAnalystR")
metanr_packages <- function(){
metr_pkgs <- c("Rserve", "RColorBrewer", "xtable", "som", "ROCR", "RJSONIO", "gplots", "e1071", "caTools", "igraph", "randomForest", "Cairo", "pls", "pheatmap", "lattice", "rmarkdown", "knitr", "data.table", "pROC", "Rcpp", "caret", "ellipse",
"scatterplot3d", "impute", "pcaMethods", "siggenes", "globaltest", "GlobalAncova", "Rgraphviz", "KEGGgraph", "preprocessCore", "genefilter", "SSPA", "sva")
list_installed <- installed.packages()
new_pkgs <- subset(metr_pkgs, !(metr_pkgs %in% list_installed[, "Package"]))
if(length(new_pkgs)!=0){
source("https://bioconductor.org/biocLite.R")
biocLite(new_pkgs, dependencies = TRUE, ask = FALSE)
print(c(new_pkgs, " packages added..."))
}
if((length(new_pkgs)<1)){
print("No new packages added...")
}
}
metanr_packages()
if((length(new_pkgs)<1)){
print("No new packages added...")
}
metanr_packages <- function(){
metr_pkgs <- c("Rserve", "RColorBrewer", "xtable", "som", "ROCR", "RJSONIO", "gplots", "e1071", "caTools", "igraph", "randomForest", "Cairo", "pls", "pheatmap", "lattice", "rmarkdown", "knitr", "data.table", "pROC", "Rcpp", "caret", "ellipse",
"scatterplot3d", "impute", "pcaMethods", "siggenes", "globaltest", "GlobalAncova", "Rgraphviz", "KEGGgraph", "preprocessCore", "genefilter", "SSPA", "sva")
list_installed <- installed.packages()
new_pkgs <- subset(metr_pkgs, !(metr_pkgs %in% list_installed[, "Package"]))
if(length(new_pkgs)!=0){
source("https://bioconductor.org/biocLite.R")
biocLite(new_pkgs, dependencies = TRUE, ask = FALSE)
print(c(new_pkgs, " packages added..."))
}
if((length(new_pkgs)<1)){
print("No new packages added...")
}
}
metanr_packages()
version
version
setwd("/Volumes/Seagate Expansion Drive/TQS_Hil")
hil<-read.csv("1_qa/hil_perCell.csv", header=TRUE)
head(hil)
library(ggplot2)
col<-c("#FFCC00","#FF9900", "#FF6600", "#FF3300",
"#990000", "#660000", "#330000", "#000000")
m<-ggplot(hi.sum, aes(x=order, y=totalSignal))+
geom_point(aes(color=time))+
xlab("Injection Order")+ylab("Total signal per cell")+
scale_color_gradientn(colors=col)+
ggtitle("Targeted HILIC \nTotal signal vs. Injeciton Order")
hi.sum<-data.frame(hi$sample, hi$order, hi$time, hi$totalSignal)
hi.sum<-data.frame(hil$sample, hil$order, hil$time, hil$totalSignal)
colnames(hi.sum)<-c("sample", "order", "time", "totalSignal")
library(ggplot2)
col<-c("#FFCC00","#FF9900", "#FF6600", "#FF3300",
"#990000", "#660000", "#330000", "#000000")
m<-ggplot(hi.sum, aes(x=order, y=totalSignal))+
geom_point(aes(color=time))+
xlab("Injection Order")+ylab("Total signal per cell")+
scale_color_gradientn(colors=col)+
ggtitle("Targeted HILIC \nTotal signal vs. Injeciton Order")
m+theme_bw()
ggsave("1_qa/HIL_totalvorder.JPEG")
m<-ggplot(hi, aes(x=hi$time, y=hi$totalSignal))+
geom_point(aes(color=time))+
xlab("Time (hour)")+ylab("Total signal per cell")+
scale_color_gradientn(colors=col)+
ggtitle("Targeted HILIC \nTotal signal vs. Time")
m<-ggplot(hil, aes(x=hi$time, y=hi$totalSignal))+
geom_point(aes(color=time))+
xlab("Time (hour)")+ylab("Total signal per cell")+
scale_color_gradientn(colors=col)+
ggtitle("Targeted HILIC \nTotal signal vs. Time")
m+theme_bw()
m<-ggplot(hil, aes(x=time, y=totalSignal))+
geom_point(aes(color=time))+
xlab("Time (hour)")+ylab("Total signal per cell")+
scale_color_gradientn(colors=col)+
ggtitle("Targeted HILIC \nTotal signal vs. Time")
m+theme_bw()
ggsave("1_qa/HIL_totalvtime.JPEG")
dim(hi.sum)
hi.sum.qc<-data.frame(ei.sum[70:85,])
hi.sum.qc<-data.frame(hi.sum[70:85,])
hi.sum[70:85,]
hi.sum.qc<-data.frame(hi.sum[73:85,])
hi.fit.qc<-lm(hi.sum.qc$order~hi.sum.qc$totalSignal, data=hi.sum.qc)
summary(ei.fit.qc)
summary(hi.fit.qc)
m<-ggplot(hi.sum.m, aes(x=order, y=value))+
geom_point(aes(color=time))
m+scale_color_gradientn(colors=col)+
geom_text(aes(label=number), hjust=-0.5, size=3)+
xlab("Injection order")+ylab("Total signal per cell")+theme_bw()+
stat_smooth(method="lm", data=ei.sum.qc.m, aes(x=order, y=value), se=FALSE)+
ggtitle("GCMS, Aqueous \nQC linear regression line, R^2=0.52")
hi.sum.qc.m<-melt(hi.sum.qc, id.vars= c("sample", "order", "time"))
library(reshape2)
hi.sum.qc.m<-melt(hi.sum.qc, id.vars= c("sample", "order", "time"))
summary(hi.fit.qc)
m<-ggplot(hi.sum.m, aes(x=order, y=value))+
geom_point(aes(color=time))
hi.sum.m<-melt(hi.sum, id.vars= c("sample", "order", "time"))
m<-ggplot(hi.sum.m, aes(x=order, y=value))+
geom_point(aes(color=time))
m+scale_color_gradientn(colors=col)+
geom_text(aes(label=number), hjust=-0.5, size=3)+
xlab("Injection order")+ylab("Total signal per cell")+theme_bw()+
stat_smooth(method="lm", data=hi.sum.qc.m, aes(x=order, y=value), se=FALSE)+
ggtitle("GCMS, Aqueous \nQC linear regression line, R^2=0.52")
hi.sum.m
m+scale_color_gradientn(colors=col)+
xlab("Injection order")+ylab("Total signal per cell")+theme_bw()+
stat_smooth(method="lm", data=hi.sum.qc.m, aes(x=order, y=value), se=FALSE)+
ggtitle("GCMS, Aqueous \nQC linear regression line, R^2=0.52")
ggsave("1_qa/HI_totalvInjection_QCregression.JPEG")
m+scale_color_gradientn(colors=col)+
xlab("Injection order")+ylab("Total signal per cell")+theme_bw()+
stat_smooth(method="lm", data=hi.sum.qc.m, aes(x=order, y=value), se=FALSE)+
ggtitle("HILIC-MS, Aqueous \nQC linear regression line, R^2=0.52")
ggsave("1_qa/HI_totalvInjection_QCregression.JPEG")
hil<-read.csv("HIL_perCell_pareto.csv")
hil<-read.csv("1_qa/HIL_perCell_pareto.csv")
dim(hil)
hi[1:2,7:96]
hi<-read.csv("1_qa/HIL_perCell_pareto.csv")
hi[1:2,7:96]
#run PCA with qc samplesl
hi.pca<-prcomp(hi[1:2,7:96], scale=FALSE)
summary(hi.pca)
#run PCA with qc samplesl
hi.pca<-prcomp(hi[,7:96], scale=FALSE)
summary(hi.pca)
summary(hi.pca)
hi[1:2,1:7]
hil<-read.csv("1_qa/HIL_perCell_pareto.csv")
hi<-read.csv("1_qa/HIL_perCell_pareto.csv")
hi[1:2,1:7]
hil<-read.csv("1_qa/hil_perCell.csv", header=TRUE)
hil[1:2,1:7]
hil[1:2,1:8]
hi.pareto<-paretoscale(hil[,8:103], exclude=FALSE)
hi.pareto<-data.frame(hil[,1:7], hi.pareto)
#scale per-cell data -- pareto
library(RFmarkerDetector)
hi.pareto<-paretoscale(hil[,8:103], exclude=FALSE)
hi.pareto<-data.frame(hil[,1:7], hi.pareto)
write.csv(hi.pareto, file="1_qa/HI_perCell_pareto.csv", row.names=FALSE)
#scale per-cell data -- autoscale (zscale)
hi.zscale<-scale(hil[,8:103], center=TRUE, scale=TRUE)
hi.zscale<-data.frame(hil[,1:7], hi.zscale)
write.csv(hi.zscale, file="1_qa/HIL_perCell_zscale.csv", row.names=FALSE)
hi<-read.csv("1_qa/HIL_perCell_pareto.csv")
hi[1:2,1:7]
hil<-read.csv("1_qa/hil_perCell.csv", header=TRUE)
hil[1:2,1:8]
hil[,1:8]
hil[,1:7]
#scale per-cell data -- autoscale (zscale)
hi.zscale<-scale(hil[,8:103], center=TRUE, scale=TRUE)
hi.zscale<-data.frame(hil[,1:7], hi.zscale)
hi.zscale[1:2,1:9]
write.csv(hi.zscale, file="1_qa/HIL_perCell_zscale.csv")
write.csv(hi.zscale, file="1_qa/HIL_perCell_zscale.csv", row.names = FALSE)
hi.pareto<-paretoscale(hil[,8:103], exclude=FALSE)
hi.pareto<-data.frame(hil[,1:7], hi.pareto)
hi.parteo[1:2,1:9]
hi.pareto[1:2,1:9]
hi<-hi.pareto
dim(hi)
#run PCA with qc samplesl
hi.pca<-prcomp(hi[,7:103], scale=FALSE)
hi[1:2,7:103]
#run PCA with qc samplesl
hi.pca<-prcomp(hi[,8:103], scale=FALSE)
hi.pca.summary<-summary(hi.pca)
summary(hi.pca)
hi.pca.scores<-data.frame(hi[,1:7], hi.pca$x)
hi.pca.scores
hi.pca.scores$rep<-as.factor(hi.pca.scores$rep)
hi.pca.load<-data.frame(hi.pca$rotation)
write.csv(hi.pca.summary$importance, file="2_pca/HI_pareto_pca_importance.csv", row.names=TRUE)
write.csv(hi.pca.scores, file="2_pca/HI_pareto_pca_scores.csv", row.names=FALSE)
write.csv(hi.pca.load, file="2_pca/HI_pareto_pca_loadings.csv")
library(ggplot2)
col<-c("#FFCC00","#FF9900", "#FF6600", "#FF3300",
"#990000", "#660000", "#330000", "#000000")
#pc 1v2
m<-ggplot(hi.pca.scores, aes(x=PC1, y=PC2))+
geom_point(aes(color=time, shape=rep), size=4)
m+labs(color="Time", shape="Bio. Rep.")+xlab("PC 1")+ylab("PC 2")+
scale_color_gradientn(colors=col)+theme_bw()+
ggtitle("HILIC, Aqueous \nPC 2 v. 4, Scores Plot")
ggsave("2_pca/HI_pareto_pca_2v4_scores.JPEG")
n<-ggplot(hi.pca.load, aes(x=PC1, y=PC2))+geom_point(size=4)
m+labs(color="Time", shape="Bio. Rep.")+xlab("PC 1")+ylab("PC 2")+
scale_color_gradientn(colors=col)+theme_bw()+
ggtitle("HILIC, Aqueous \nPC 1 v. 2, Scores Plot")
ggsave("2_pca/HI_pareto_pca_2v4_scores.JPEG")
n+xlab("PC 1")+ylab("PC 2")+theme_bw()+
geom_text(aes(label=rownames(ei.pca.load)), vjust=1)+
ggtitle("HILIC, Aqueous \nPC 1 v. 2, Loadings Plot")
n+xlab("PC 1")+ylab("PC 2")+theme_bw()+
geom_text(aes(label=rownames(hi.pca.load)), vjust=1)+
ggtitle("HILIC, Aqueous \nPC 1 v. 2, Loadings Plot")
n+xlab("PC 1")+ylab("PC 2")+theme_bw()+
geom_text(aes(label=rownames(hi.pca.load)), vjust=2)+
ggtitle("HILIC, Aqueous \nPC 1 v. 2, Loadings Plot")
n<-ggplot(hi.pca.load, aes(x=PC1, y=PC2))+geom_point(size=2)
n+xlab("PC 1")+ylab("PC 2")+theme_bw()+
geom_text(aes(label=rownames(hi.pca.load)), vjust=2)+
ggtitle("HILIC, Aqueous \nPC 1 v. 2, Loadings Plot")
n+xlab("PC 1")+ylab("PC 2")+theme_bw()+
geom_text(aes(label=rownames(hi.pca.load)), vjust=2, hjust=1)+
ggtitle("HILIC, Aqueous \nPC 1 v. 2, Loadings Plot")
n+xlab("PC 1")+ylab("PC 2")+theme_bw()+
geom_text(aes(label=rownames(hi.pca.load)), vjust=2, hjust=-1)+
ggtitle("HILIC, Aqueous \nPC 1 v. 2, Loadings Plot")
n+xlab("PC 1")+ylab("PC 2")+theme_bw()+
geom_text(aes(label=rownames(hi.pca.load)), vjust=2)+
ggtitle("HILIC, Aqueous \nPC 1 v. 2, Loadings Plot")
#pc 1v2
m<-ggplot(hi.pca.scores, aes(x=PC1, y=PC2))+
geom_point(aes(color=time, shape=rep), size=4)
m+labs(color="Time", shape="Bio. Rep.")+xlab("PC 1")+ylab("PC 2")+
scale_color_gradientn(colors=col)+theme_bw()+
ggtitle("HILIC, Aqueous \nPC 1 v. 2, Scores Plot")
ggsave("2_pca/HI_pareto_pca_1v2_scores.JPEG")
n<-ggplot(hi.pca.load, aes(x=PC1, y=PC2))+geom_point(size=2)
n+xlab("PC 1")+ylab("PC 2")+theme_bw()+
geom_text(aes(label=rownames(hi.pca.load)), vjust=2)+
ggtitle("HILIC, Aqueous \nPC 1 v. 2, Loadings Plot")
ggsave("2_pca/HI_pareto_pca_1v2_load.JPEG")
