This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Execute the chunk of codes by clicking the Run button (>) within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
options(repos=c(CRAN="https://mirror.las.iastate.edu/CRAN/"))
knitr::opts_knit$set(root.dir = "R:/Biology/BIOL-4129-5129/hickljaa/Lab13_LC-MS")
getwd()
## [1] "R:/Biology/BIOL-4129-5129/hickljaa/Lab13_LC-MS"
#### By default, R displays all possible output from a code chunk, including messages, warnings, and plots. The code message=FALSE prevents printing package loading messages to the output below the code chunk instead prints them to the console.
library(rmarkdown)
library(knitr)
library(yaml)
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
library(BiocManager)
BiocManager::install(c("limma", "edgeR", "vsn", "pcaMethods"))
## 'getOption("repos")' replaces Bioconductor standard repositories, see
## 'help("repositories", package = "BiocManager")' for details.
## Replacement repositories:
## CRAN: https://mirror.las.iastate.edu/CRAN/
## Bioconductor version 3.20 (BiocManager 1.30.25), R 4.4.2 (2024-10-31 ucrt)
## Warning: package(s) not installed when version(s) same as or greater than current; use
## `force = TRUE` to re-install: 'limma' 'edgeR' 'vsn' 'pcaMethods'
## Installation paths not writeable, unable to update packages
## path: C:/Program Files/R/R-4.4.2/library
## packages:
## cluster
install.packages(c("psych", "gplots", "missMethods"))
## Installing packages into 'C:/Users/hickljaa/AppData/Local/R/win-library/4.4'
## (as 'lib' is unspecified)
## package 'psych' successfully unpacked and MD5 sums checked
## package 'gplots' successfully unpacked and MD5 sums checked
## package 'missMethods' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\hickljaa\AppData\Local\Temp\5\RtmpSQ4S9e\downloaded_packages
library("limma")
library("edgeR")
library("vsn")
## Loading required package: Biobase
## Loading required package: BiocGenerics
##
## Attaching package: 'BiocGenerics'
## The following object is masked from 'package:limma':
##
## plotMA
## The following objects are masked from 'package:stats':
##
## IQR, mad, sd, var, xtabs
## The following objects are masked from 'package:base':
##
## anyDuplicated, aperm, append, as.data.frame, basename, cbind,
## colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find,
## get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply,
## match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
## Position, rank, rbind, Reduce, rownames, sapply, saveRDS, setdiff,
## table, tapply, union, unique, unsplit, which.max, which.min
## Welcome to Bioconductor
##
## Vignettes contain introductory material; view with
## 'browseVignettes()'. To cite Bioconductor, see
## 'citation("Biobase")', and for packages 'citation("pkgname")'.
library("pcaMethods")
##
## Attaching package: 'pcaMethods'
## The following object is masked from 'package:stats':
##
## loadings
library("psych")
##
## Attaching package: 'psych'
## The following object is masked from 'package:pcaMethods':
##
## pca
library(gplots)
##
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
##
## lowess
library(missMethods)
proteinGroups <-read.table(file = "proteinGroups_Lab13.tabular", header = TRUE, row.names = 1, sep="\t")
View(proteinGroups)
filtered_data = proteinGroups[!proteinGroups$Only.identified.by.site=="+",] # the $ operator is used to subset (extract) a specific part of the data. Here we are pulling elements (rows) from the data when the Only.identified.by.site column contains a +.
filtered_data = filtered_data[!filtered_data$Reverse=="+",] # Here we are pulling elements from the data when Reverse is +.Note that, ! is logical NOT operator in R.
filtered_data = filtered_data[!filtered_data$Potential.contaminant=="+",] # And here we are pulling elements from the data when the values for the Potential.contaminant column is +.
LFQ = filtered_data[,57:62]
LFQ[LFQ==0] <- NA
total<-(colSums(LFQ[,1:6],na.rm=TRUE)) # to find column totals using the colSums() function and na.rm to ignor missing values
barplot(t(as.matrix(total)),mar=c(5.1, 4.1, 4.1, 2.1)) # vertical barplot of column totals
col_nas= colSums(is.na(LFQ)) # Total number of NAs per column in a data frame
col_total=colSums (LFQ, na.rm = T, dims = 1) # Column totals
col_percent = (col_nas * 100 )/(nrow(LFQ))# Percentage of missing values per column
barplot(t(as.matrix(col_percent)))
Filtered_LFQ=LFQ[rowSums(is.na(LFQ))<(length(LFQ)-1),]
Normalized <- justvsn(as.matrix(Filtered_LFQ))
meanSdPlot(Normalized, ranks = TRUE)
multi.hist(Normalized, dcol= c("blue","red"),dlty=c("dotted", "solid"), main="histograms with density plots of normalized data_Lab13_38a")
boxplot(Normalized, main="Boxplot of normalized data_Lab13_38b", col=" light blue")
plotMDS(Normalized, main="MDS plot of normalized data_Lab13_38c")
imputed<-impute_LS_adaptive(Normalized)
View(imputed)
multi.hist(imputed, dcol= c("blue","red"),dlty=c("dotted", "solid"), main="histograms with density plots of normalized and imputed data_Lab13_39b")
boxplot(imputed, main="Boxplot of normalized and imputed data_Lab13_39b", cex.main = 1, col="light blue")
plotDensities(imputed,legend="topright",inset=c(-3, 0),names(samples), main="Density plots of normalized and imputed data_Lab13_39b") # The inset(x, y) argument can be used to control the location of the legend to the right of the plot. For example, we can make the x argument more negative to push the legend even further to the right and make y more positive to push it lower.
## Warning: In density.default(E[, a], n = npoint, na.rm = TRUE, ...) :
## extra argument 'inset' will be disregarded
## Warning: In density.default(E[, a], n = npoint, na.rm = TRUE, ...) :
## extra argument 'inset' will be disregarded
## Warning: In density.default(E[, a], n = npoint, na.rm = TRUE, ...) :
## extra argument 'inset' will be disregarded
## Warning: In density.default(E[, a], n = npoint, na.rm = TRUE, ...) :
## extra argument 'inset' will be disregarded
## Warning: In density.default(E[, a], n = npoint, na.rm = TRUE, ...) :
## extra argument 'inset' will be disregarded
## Warning: In density.default(E[, a], n = npoint, na.rm = TRUE, ...) :
## extra argument 'inset' will be disregarded
plotMDS(imputed, main="MDS plot of normalized and imputed data_Lab13_39b", cex.main = 1)
coolmap(imputed, "Heatmap of normalized and imputed data_Lab13_39b", cluster.by="de pattern", col=NULL, linkage.row="complete", linkage.col="complete", show.dendrogram="both")
Group <-factor(rep(c("healthy","psoriasis"), each=3)) # factor() converts the vector into a factor. rep(c("healthy","psoriasis"), each = 3) creates a vector by repeating the sequence ("healthy", "psoriasis") three times. The sequence is not dynamic — it's defined by you.
Group
## [1] healthy healthy healthy psoriasis psoriasis psoriasis
## Levels: healthy psoriasis
Design <- model.matrix(~Group) # Here we only have two groups and one possible comparison for differential expression of proteins. We can remove the intercept in the model.matrix by adding 0, i.e., (~0+group). This will allow specific pairwise comparisons without sacrificing one level as a reference. However, since we only have two levels, the result will be the same.
head(Design) # shows the design matrix
## (Intercept) Grouppsoriasis
## 1 1 0
## 2 1 0
## 3 1 0
## 4 1 1
## 5 1 1
## 6 1 1
colnames(Design) # shows how the coefficients are defined
## [1] "(Intercept)" "Grouppsoriasis"
Design # lists the columns with their contrast coefficients.
## (Intercept) Grouppsoriasis
## 1 1 0
## 2 1 0
## 3 1 0
## 4 1 1
## 5 1 1
## 6 1 1
## attr(,"assign")
## [1] 0 1
## attr(,"contrasts")
## attr(,"contrasts")$Group
## [1] "contr.treatment"
fit <- lmFit(imputed,Design)
efit <- eBayes(fit)
topTable(efit) # Default is 20 genes/proteins.
## Removing intercept from test coefficients
## logFC
## P31151 5.739511
## P48594;H0Y5H9;C9JZ65 10.473871
## A0A7I2V2P6;A0A3B3ISG5;P14735;A0A7I2V3E3;A0A7I2YQV5;A0A7I2V610;A0A7I2V4Q3;A0A7I2V2S1;A0A7I2V3K9;B3KSB8;P14735-2;A0A7I2YQS6;A0A7I2V612;A0A7I2V373;A0A7I2V4A4;A0A7I2V634 4.519826
## P15502-2;E7ENM0;E7EN65;P15502-4;P15502-1;P15502-9;E7ETP7;P15502;P15502-10;P15502-5;P15502-13;P15502-6;P15502-7;P15502-12;P15502-8;G3V0G6;G5E950;B3KRT8;E7EWS8;P15502-11;E7ENW7;E7EP82;E7EQH8 -2.393218
## P12236 1.293670
## Q01469;I6L8B7;A8MUU1;REV__Q5QNW6-2;REV__Q16778;REV__Q99879;REV__Q99877;REV__Q93079;REV__Q8N257;REV__Q5QNW6;REV__U3KQK0;REV__P58876;REV__P57053;REV__P33778;REV__P23527;REV__P06899;REV__O60814;REV__Q99880;REV__P62807 4.307138
## P43490;A0A7P0T9I9;A0A7P0T973;A0A7P0T931;A0A7P0T895;A0A7P0T8L3;A0A7P0TAS5;A0A7P0T862;A0A7P0T8D2;A0A0C4DFS8;A0A7P0TA73;A0A7P0TBB7;A0A7P0T941;A0A7P0Z466;B7Z8W6;A0A7P0Z4N0;A0A7P0T9F0;A0A7P0TB17;A0A7P0T8Z3;A0A7P0T8R4;A0A7P0TAI8;A0A7P0Z437;A0A7P0Z4L4;C9JG65;C9JF35;A0A7P0TAZ2 3.611664
## P42224;P42224-2;A0A669KB53;A0A669KBA4;A0A669KB56;A0A669KB68;A0A669KBI6;J3KPM9;A0A669KB52;A0A669KB75;E7EPD2;A0A669KB17;D2KFR9;E7ENM1;Q67C41;E9PH66;A0A669KBK4 2.157990
## Q59GN2;P62891 1.498487
## A0A087WW43;Q06033-2;Q06033;E7ET33 -1.474476
## AveExpr
## P31151 28.66029
## P48594;H0Y5H9;C9JZ65 24.78164
## A0A7I2V2P6;A0A3B3ISG5;P14735;A0A7I2V3E3;A0A7I2YQV5;A0A7I2V610;A0A7I2V4Q3;A0A7I2V2S1;A0A7I2V3K9;B3KSB8;P14735-2;A0A7I2YQS6;A0A7I2V612;A0A7I2V373;A0A7I2V4A4;A0A7I2V634 25.75188
## P15502-2;E7ENM0;E7EN65;P15502-4;P15502-1;P15502-9;E7ETP7;P15502;P15502-10;P15502-5;P15502-13;P15502-6;P15502-7;P15502-12;P15502-8;G3V0G6;G5E950;B3KRT8;E7EWS8;P15502-11;E7ENW7;E7EP82;E7EQH8 26.30979
## P12236 26.17132
## Q01469;I6L8B7;A8MUU1;REV__Q5QNW6-2;REV__Q16778;REV__Q99879;REV__Q99877;REV__Q93079;REV__Q8N257;REV__Q5QNW6;REV__U3KQK0;REV__P58876;REV__P57053;REV__P33778;REV__P23527;REV__P06899;REV__O60814;REV__Q99880;REV__P62807 28.91527
## P43490;A0A7P0T9I9;A0A7P0T973;A0A7P0T931;A0A7P0T895;A0A7P0T8L3;A0A7P0TAS5;A0A7P0T862;A0A7P0T8D2;A0A0C4DFS8;A0A7P0TA73;A0A7P0TBB7;A0A7P0T941;A0A7P0Z466;B7Z8W6;A0A7P0Z4N0;A0A7P0T9F0;A0A7P0TB17;A0A7P0T8Z3;A0A7P0T8R4;A0A7P0TAI8;A0A7P0Z437;A0A7P0Z4L4;C9JG65;C9JF35;A0A7P0TAZ2 25.93944
## P42224;P42224-2;A0A669KB53;A0A669KBA4;A0A669KB56;A0A669KB68;A0A669KBI6;J3KPM9;A0A669KB52;A0A669KB75;E7EPD2;A0A669KB17;D2KFR9;E7ENM1;Q67C41;E9PH66;A0A669KBK4 25.61798
## Q59GN2;P62891 27.50380
## A0A087WW43;Q06033-2;Q06033;E7ET33 24.98124
## t
## P31151 13.162589
## P48594;H0Y5H9;C9JZ65 13.096477
## A0A7I2V2P6;A0A3B3ISG5;P14735;A0A7I2V3E3;A0A7I2YQV5;A0A7I2V610;A0A7I2V4Q3;A0A7I2V2S1;A0A7I2V3K9;B3KSB8;P14735-2;A0A7I2YQS6;A0A7I2V612;A0A7I2V373;A0A7I2V4A4;A0A7I2V634 11.001931
## P15502-2;E7ENM0;E7EN65;P15502-4;P15502-1;P15502-9;E7ETP7;P15502;P15502-10;P15502-5;P15502-13;P15502-6;P15502-7;P15502-12;P15502-8;G3V0G6;G5E950;B3KRT8;E7EWS8;P15502-11;E7ENW7;E7EP82;E7EQH8 -9.635134
## P12236 9.487154
## Q01469;I6L8B7;A8MUU1;REV__Q5QNW6-2;REV__Q16778;REV__Q99879;REV__Q99877;REV__Q93079;REV__Q8N257;REV__Q5QNW6;REV__U3KQK0;REV__P58876;REV__P57053;REV__P33778;REV__P23527;REV__P06899;REV__O60814;REV__Q99880;REV__P62807 9.413344
## P43490;A0A7P0T9I9;A0A7P0T973;A0A7P0T931;A0A7P0T895;A0A7P0T8L3;A0A7P0TAS5;A0A7P0T862;A0A7P0T8D2;A0A0C4DFS8;A0A7P0TA73;A0A7P0TBB7;A0A7P0T941;A0A7P0Z466;B7Z8W6;A0A7P0Z4N0;A0A7P0T9F0;A0A7P0TB17;A0A7P0T8Z3;A0A7P0T8R4;A0A7P0TAI8;A0A7P0Z437;A0A7P0Z4L4;C9JG65;C9JF35;A0A7P0TAZ2 8.889131
## P42224;P42224-2;A0A669KB53;A0A669KBA4;A0A669KB56;A0A669KB68;A0A669KBI6;J3KPM9;A0A669KB52;A0A669KB75;E7EPD2;A0A669KB17;D2KFR9;E7ENM1;Q67C41;E9PH66;A0A669KBK4 8.593248
## Q59GN2;P62891 8.564618
## A0A087WW43;Q06033-2;Q06033;E7ET33 -8.381633
## P.Value
## P31151 7.223586e-06
## P48594;H0Y5H9;C9JZ65 7.452247e-06
## A0A7I2V2P6;A0A3B3ISG5;P14735;A0A7I2V3E3;A0A7I2YQV5;A0A7I2V610;A0A7I2V4Q3;A0A7I2V2S1;A0A7I2V3K9;B3KSB8;P14735-2;A0A7I2YQS6;A0A7I2V612;A0A7I2V373;A0A7I2V4A4;A0A7I2V634 2.176491e-05
## P15502-2;E7ENM0;E7EN65;P15502-4;P15502-1;P15502-9;E7ETP7;P15502;P15502-10;P15502-5;P15502-13;P15502-6;P15502-7;P15502-12;P15502-8;G3V0G6;G5E950;B3KRT8;E7EWS8;P15502-11;E7ENW7;E7EP82;E7EQH8 4.868633e-05
## P12236 5.344239e-05
## Q01469;I6L8B7;A8MUU1;REV__Q5QNW6-2;REV__Q16778;REV__Q99879;REV__Q99877;REV__Q93079;REV__Q8N257;REV__Q5QNW6;REV__U3KQK0;REV__P58876;REV__P57053;REV__P33778;REV__P23527;REV__P06899;REV__O60814;REV__Q99880;REV__P62807 5.601252e-05
## P43490;A0A7P0T9I9;A0A7P0T973;A0A7P0T931;A0A7P0T895;A0A7P0T8L3;A0A7P0TAS5;A0A7P0T862;A0A7P0T8D2;A0A0C4DFS8;A0A7P0TA73;A0A7P0TBB7;A0A7P0T941;A0A7P0Z466;B7Z8W6;A0A7P0Z4N0;A0A7P0T9F0;A0A7P0TB17;A0A7P0T8Z3;A0A7P0T8R4;A0A7P0TAI8;A0A7P0Z437;A0A7P0Z4L4;C9JG65;C9JF35;A0A7P0TAZ2 7.894926e-05
## P42224;P42224-2;A0A669KB53;A0A669KBA4;A0A669KB56;A0A669KB68;A0A669KBI6;J3KPM9;A0A669KB52;A0A669KB75;E7EPD2;A0A669KB17;D2KFR9;E7ENM1;Q67C41;E9PH66;A0A669KBK4 9.658239e-05
## Q59GN2;P62891 9.851602e-05
## A0A087WW43;Q06033-2;Q06033;E7ET33 1.119747e-04
## adj.P.Val
## P31151 0.006207722
## P48594;H0Y5H9;C9JZ65 0.006207722
## A0A7I2V2P6;A0A3B3ISG5;P14735;A0A7I2V3E3;A0A7I2YQV5;A0A7I2V610;A0A7I2V4Q3;A0A7I2V2S1;A0A7I2V3K9;B3KSB8;P14735-2;A0A7I2YQS6;A0A7I2V612;A0A7I2V373;A0A7I2V4A4;A0A7I2V634 0.012086778
## P15502-2;E7ENM0;E7EN65;P15502-4;P15502-1;P15502-9;E7ETP7;P15502;P15502-10;P15502-5;P15502-13;P15502-6;P15502-7;P15502-12;P15502-8;G3V0G6;G5E950;B3KRT8;E7EWS8;P15502-11;E7ENW7;E7EP82;E7EQH8 0.015552811
## P12236 0.015552811
## Q01469;I6L8B7;A8MUU1;REV__Q5QNW6-2;REV__Q16778;REV__Q99879;REV__Q99877;REV__Q93079;REV__Q8N257;REV__Q5QNW6;REV__U3KQK0;REV__P58876;REV__P57053;REV__P33778;REV__P23527;REV__P06899;REV__O60814;REV__Q99880;REV__P62807 0.015552811
## P43490;A0A7P0T9I9;A0A7P0T973;A0A7P0T931;A0A7P0T895;A0A7P0T8L3;A0A7P0TAS5;A0A7P0T862;A0A7P0T8D2;A0A0C4DFS8;A0A7P0TA73;A0A7P0TBB7;A0A7P0T941;A0A7P0Z466;B7Z8W6;A0A7P0Z4N0;A0A7P0T9F0;A0A7P0TB17;A0A7P0T8Z3;A0A7P0T8R4;A0A7P0TAI8;A0A7P0Z437;A0A7P0Z4L4;C9JG65;C9JF35;A0A7P0TAZ2 0.017637780
## P42224;P42224-2;A0A669KB53;A0A669KBA4;A0A669KB56;A0A669KB68;A0A669KBI6;J3KPM9;A0A669KB52;A0A669KB75;E7EPD2;A0A669KB17;D2KFR9;E7ENM1;Q67C41;E9PH66;A0A669KBK4 0.017637780
## Q59GN2;P62891 0.017637780
## A0A087WW43;Q06033-2;Q06033;E7ET33 0.017637780
## B
## P31151 4.404941
## P48594;H0Y5H9;C9JZ65 4.379322
## A0A7I2V2P6;A0A3B3ISG5;P14735;A0A7I2V3E3;A0A7I2YQV5;A0A7I2V610;A0A7I2V4Q3;A0A7I2V2S1;A0A7I2V3K9;B3KSB8;P14735-2;A0A7I2YQS6;A0A7I2V612;A0A7I2V373;A0A7I2V4A4;A0A7I2V634 3.457962
## P15502-2;E7ENM0;E7EN65;P15502-4;P15502-1;P15502-9;E7ETP7;P15502;P15502-10;P15502-5;P15502-13;P15502-6;P15502-7;P15502-12;P15502-8;G3V0G6;G5E950;B3KRT8;E7EWS8;P15502-11;E7ENW7;E7EP82;E7EQH8 2.719796
## P12236 2.632107
## Q01469;I6L8B7;A8MUU1;REV__Q5QNW6-2;REV__Q16778;REV__Q99879;REV__Q99877;REV__Q93079;REV__Q8N257;REV__Q5QNW6;REV__U3KQK0;REV__P58876;REV__P57053;REV__P33778;REV__P23527;REV__P06899;REV__O60814;REV__Q99880;REV__P62807 2.587752
## P43490;A0A7P0T9I9;A0A7P0T973;A0A7P0T931;A0A7P0T895;A0A7P0T8L3;A0A7P0TAS5;A0A7P0T862;A0A7P0T8D2;A0A0C4DFS8;A0A7P0TA73;A0A7P0TBB7;A0A7P0T941;A0A7P0Z466;B7Z8W6;A0A7P0Z4N0;A0A7P0T9F0;A0A7P0TB17;A0A7P0T8Z3;A0A7P0T8R4;A0A7P0TAI8;A0A7P0Z437;A0A7P0Z4L4;C9JG65;C9JF35;A0A7P0TAZ2 2.260448
## P42224;P42224-2;A0A669KB53;A0A669KBA4;A0A669KB56;A0A669KB68;A0A669KBI6;J3KPM9;A0A669KB52;A0A669KB75;E7EPD2;A0A669KB17;D2KFR9;E7ENM1;Q67C41;E9PH66;A0A669KBK4 2.065715
## Q59GN2;P62891 2.046471
## A0A087WW43;Q06033-2;Q06033;E7ET33 1.921763
DE_proteins <- decideTests(efit, n=Inf) # method="separate" and adjust.method = "BH"' are default
summary(DE_proteins) # lists the number of up-/down-regulated proteins in psoriasis compared to healthy skin.
## (Intercept) Grouppsoriasis
## Down 0 96
## NotSig 0 1491
## Up 1666 79
View (DE_proteins)