colvec <- c("cornflowerblue", "brown3") namevec <- c("HC (T0)", "SLE (T0)") boxplot(y ~ group, col = colvec, xlab = "", ylab = "Percent Positive", main = plottitle, frame.plot = FALSE, outline = F, ylim = c(0, ymax), names = namevec, cex.axis = 0.9, cex.lab = 0.95, lwd = 0.5) box(bty="l") set.seed(8) y <- rnorm(200) group <- sample(LETTERS[1:2], size = 200, replace = TRUE) stripchart(y ~ group, pch = 16, vertical = TRUE, cex = 0.5, method = "jitter", col = adjustcolor("black", alpha = 0.7), add = TRUE) # install.packages("ggplot2") library(ggplot2) # Data set.seed(8) y <- rnorm(200) group <- sample(LETTERS[1:2], size = 200, replace = TRUE) df <- data.frame(y, group) # Box plot by group with jitter ggplot(df, aes(x = group, y = y, colour = group)) + geom_boxplot(outlier.shape = NA) + scale_color_manual(values=c("red", "black"))+ #scale_fill_manual(values=c("blue", "red"))+ geom_jitter(aes(colour=group)) + xlab("")+ theme( panel.background = element_rect(fill = "white", colour = "grey50"), legend.position = "none") ##### LN vs NLN library(openxlsx) a <- loadWorkbook('/Users/tushar/Desktop/Dxterity2/Dxterity41.xlsx') sheetNames <- sheets(a) a11<- read.xlsx('/Users/tushar/Desktop/Dxterity2/Dxterity41.xlsx', sheet=3) #a11[21:40,1:7] dim(a11) colnames(a11) rownames(a11) which(colnames(a11)=="Timepoint") ### 7 to 40 row_hc<- which(a11[,7]==0 & a11[,4]=="SLE" & a11[,5]=="A") row_A<- which(a11[,7]==1 & a11[,4]=="SLE" & a11[,5]=="A") length(row_hc) length(row_A) data_hc<- a11[c(row_hc),c(10,12:20)] dim(data_hc) data_NLN<- a11[c(row_hc),c(10,12:20)] dim(data_NLN) data_LN<- a11[c(row_A),c(10,12:20)] dim(data_LN) data_NLN_LN <- rbind(data_NLN, data_LN) LN_cond<- factor(c(rep("No Lupus Nephritis",dim(data_NLN)[1]), rep("Lupus Nephritis",dim(data_LN)[1])), levels=c("No Lupus Nephritis", "Lupus Nephritis")) Expression<- data_NLN_LN$Plasmablasts.Module df2 <- data.frame(Expression, LN_cond) # Box plot by group with jitter p21<- ggplot(df2, aes(x = LN_cond, y = Expression, colour = LN_cond)) + geom_boxplot() + scale_color_manual(values=c("black", "red"))+ #scale_fill_manual(values=c("blue", "red"))+ geom_jitter(aes(colour=LN_cond)) + xlab("")+ ylab("DxTerity IFN Module expression")+ theme( panel.background = element_rect(fill = "white", colour = "grey50"), legend.position = "none") pdf("/Users/tushar/Desktop/Dxterity2/Boxplot_Plasmablasts_LNvsNLN_v3.pdf", 5,5) p21 dev.off() ##### HC vs SLE library(openxlsx) a <- loadWorkbook('/Users/tushar/Desktop/Dxterity2/Dxterity41.xlsx') sheetNames <- sheets(a) a11<- read.xlsx('/Users/tushar/Desktop/Dxterity2/Dxterity41.xlsx', sheet=3) a11[1:5,1:5] dim(a11) colnames(a11) rownames(a11) which(colnames(a11)=="Timepoint") ### 7 to 40 row_hc<- which(a11[,5]=="HC") row_A<- which(a11[,5]=="A" & a11[,4]=="SLE") length(row_hc) length(row_A) data_hc<- a11[c(row_hc),c(10,12:20)] dim(data_hc) data_NLN<- a11[c(row_hc),c(10,12:20)] dim(data_NLN) data_LN<- a11[c(row_A),c(10,12:20)] dim(data_LN) data_NLN_LN <- rbind(data_NLN, data_LN) LN_cond<- c(rep("Healthy Control",dim(data_NLN)[1]), rep("SLE",dim(data_LN)[1])) Expression<- data_NLN_LN$Plasmablasts.Module df2 <- data.frame(Expression, LN_cond) df2 <- data.frame(Expression, LN_cond) # Box plot by group with jitter p21<- ggplot(df2, aes(x = LN_cond, y = Expression, colour = LN_cond)) + geom_boxplot() + scale_color_manual(values=c( "black", "red"))+ #scale_fill_manual(values=c("blue", "red"))+ geom_jitter(aes(colour=LN_cond)) + xlab("")+ ylab("DxTerity IFN Module expression")+ theme( panel.background = element_rect(fill = "white", colour = "grey50"), legend.position = "none") pdf("/Users/tushar/Desktop/Dxterity2/Boxplot_Plasmablasts_HCvsSLE_v3.pdf", 5,5) p21 dev.off() tapply(df2$Expression, df2$LN_cond, summary) tapply(df2$Expression, df2$LN_cond, sd)