################################################################################# # NIH Biowulf Node Launch ################################################################################# sinteractive --mem 500g --time 36:00:00 --gres=lscratch:500 ################################################################################# # Load and Launch R ################################################################################# module load R/3.6.1 Rstudio rstudio & ################################################################################# # Initiate Envrinment & Install Dependencies ################################################################################# library(gplots) library(stringr) library(data.table) require(data.table) library(Seurat) library(ggplot2) library(sctransform) library(scales) require(scales) library(imager) ################################################################################# # Identify number bins per bulb ################################################################################# setwd("/data/johnsonko/SideProject/Helen/20200811/Bulb_Images") # AZ_109_146 working.im <- load.image("AZ109.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_AZ109.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_AZ109.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } # AZ_84_145 working.im <- load.image("/data/johnsonko/SideProject/Helen/Bulb_Images/AZ84.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_AZ84.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_AZ84.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } # AZ_90_242 working.im <- load.image("/data/johnsonko/SideProject/Helen/Bulb_Images/AZ90.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_AZ90.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_AZ90.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } # AZ_99_140 working.im <- load.image("/data/johnsonko/SideProject/Helen/Bulb_Images/AZ99.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_AZ99.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_AZ99.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } # Control_H190_260 working.im <- load.image("/data/johnsonko/SideProject/Helen/Bulb_Images/H190.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_H190.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_H190.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } # NewH250 working.im <- load.image("/data/johnsonko/SideProject/Helen/Bulb_Images/H250.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_H250.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_H250.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } # AZ_251_146 working.im <- load.image("/data/johnsonko/SideProject/Helen/Bulb_Images/H251.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_H251.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_H251.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } # Control_OFB57_194 working.im <- load.image("/data/johnsonko/SideProject/Helen/Bulb_Images/OFB57.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_OFB57.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_OFB57.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } # Control_OFB6A_107 working.im <- load.image("/data/johnsonko/SideProject/Helen/Bulb_Images/OFB6a.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_OFB6a.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_OFB6a.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } # PD_52_247 working.im <- load.image("/data/johnsonko/SideProject/Helen/Bulb_Images/PD52.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_PD52.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_PD52.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } # PD_56_236 working.im <- load.image("/data/johnsonko/SideProject/Helen/Bulb_Images/PD56.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_PD56.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_PD56.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } # PD_58_229 working.im <- load.image("/data/johnsonko/SideProject/Helen/Bulb_Images/PD58.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_PD58.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_PD58.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } # PD_77_197 working.im <- load.image("/data/johnsonko/SideProject/Helen/Bulb_Images/PD77.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_PD77.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_PD77.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } # PD_79_201 working.im <- load.image("/data/johnsonko/SideProject/Helen/Bulb_Images/PD79.jpg") working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,"Total_Bulb_Bins_PD79.txt",row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,"Total_Bulb_Bins_PD79.txt",row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } setwd("/data/johnsonko/SideProject/Helen/20200811/Bulb_Bins") Total.Bulb.Bins.AZ109 <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_AZ109.txt",skip=1) Total.Bulb.Bins.AZ84 <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_AZ84.txt",skip=1) Total.Bulb.Bins.AZ90 <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_AZ90.txt",skip=1) Total.Bulb.Bins.AZ99 <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_AZ99.txt",skip=1) Total.Bulb.Bins.H190 <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_H190.txt",skip=1) Total.Bulb.Bins.H250 <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_H250.txt",skip=1) Total.Bulb.Bins.H251 <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_H251.txt",skip=1) Total.Bulb.Bins.OFB57 <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_OFB57.txt",skip=1) Total.Bulb.Bins.OFB6a <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_OFB6a.txt",skip=1) Total.Bulb.Bins.PD52 <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_PD52.txt",skip=1) Total.Bulb.Bins.PD56 <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_PD56.txt",skip=1) Total.Bulb.Bins.PD58 <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_PD58.txt",skip=1) Total.Bulb.Bins.PD77 <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_PD77.txt",skip=1) Total.Bulb.Bins.PD79 <- read.table("/data/johnsonko/SideProject/Helen/20200716/Total_Bulb_Bin_Counts/Total_Bulb_Bins_PD79.txt",skip=1) Total.Bulb.Bins.AZ109 <- Total.Bulb.Bins.AZ109[Total.Bulb.Bins.AZ109[,5]>0,] Total.Bulb.Bins.AZ84 <- Total.Bulb.Bins.AZ84[Total.Bulb.Bins.AZ84[,5]>0,] Total.Bulb.Bins.AZ90 <- Total.Bulb.Bins.AZ90[Total.Bulb.Bins.AZ90[,5]>0,] Total.Bulb.Bins.AZ99 <- Total.Bulb.Bins.AZ99[Total.Bulb.Bins.AZ99[,5]>0,] Total.Bulb.Bins.H190 <- Total.Bulb.Bins.H190[Total.Bulb.Bins.H190[,5]>0,] Total.Bulb.Bins.H250 <- Total.Bulb.Bins.H250[Total.Bulb.Bins.H250[,5]>0,] Total.Bulb.Bins.H251 <- Total.Bulb.Bins.H251[Total.Bulb.Bins.H251[,5]>0,] Total.Bulb.Bins.OFB57 <- Total.Bulb.Bins.OFB57[Total.Bulb.Bins.OFB57[,5]>0,] Total.Bulb.Bins.OFB6a <- Total.Bulb.Bins.OFB6a[Total.Bulb.Bins.OFB6a[,5]>0,] Total.Bulb.Bins.PD52 <- Total.Bulb.Bins.PD52[Total.Bulb.Bins.PD52[,5]>0,] Total.Bulb.Bins.PD56 <- Total.Bulb.Bins.PD56[Total.Bulb.Bins.PD56[,5]>0,] Total.Bulb.Bins.PD58 <- Total.Bulb.Bins.PD58[Total.Bulb.Bins.PD58[,5]>0,] Total.Bulb.Bins.PD77 <- Total.Bulb.Bins.PD77[Total.Bulb.Bins.PD77[,5]>0,] Total.Bulb.Bins.PD79 <- Total.Bulb.Bins.PD79[Total.Bulb.Bins.PD79[,5]>0,] dim(Total.Bulb.Bins.AZ109)[1] dim(Total.Bulb.Bins.AZ84)[1] dim(Total.Bulb.Bins.AZ90)[1] dim(Total.Bulb.Bins.AZ99)[1] dim(Total.Bulb.Bins.H190)[1] dim(Total.Bulb.Bins.H250)[1] dim(Total.Bulb.Bins.H251)[1] dim(Total.Bulb.Bins.OFB57)[1] dim(Total.Bulb.Bins.OFB6a)[1] dim(Total.Bulb.Bins.PD52)[1] dim(Total.Bulb.Bins.PD56)[1] dim(Total.Bulb.Bins.PD58)[1] dim(Total.Bulb.Bins.PD77)[1] dim(Total.Bulb.Bins.PD79)[1] temp <- Total.Bulb.Bins.AZ109 new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.AZ109",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_AZ109.txt",sep="\t") final.Bulb.Locations.AZ109 <- temp temp <- Total.Bulb.Bins.AZ84 new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.AZ84",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_AZ84.txt",sep="\t") final.Bulb.Locations.AZ84 <- temp temp <- Total.Bulb.Bins.AZ90 new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.AZ90",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_AZ90.txt",sep="\t") final.Bulb.Locations.AZ90 <- temp temp <- Total.Bulb.Bins.AZ99 new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.AZ99",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_AZ99.txt",sep="\t") final.Bulb.Locations.AZ99 <- temp temp <- Total.Bulb.Bins.H190 new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.H190",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_H190.txt",sep="\t") final.Bulb.Locations.H190 <- temp temp <- Total.Bulb.Bins.H250 new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.H250",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_H250.txt",sep="\t") final.Bulb.Locations.H250 <- temp temp <- Total.Bulb.Bins.H251 new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.H251",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_H251.txt",sep="\t") final.Bulb.Locations.H251 <- temp temp <- Total.Bulb.Bins.OFB57 new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.OFB57",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_OFB57.txt",sep="\t") final.Bulb.Locations.OFB57 <- temp temp <- Total.Bulb.Bins.OFB6a new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.OFB6a",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_OFB6a.txt",sep="\t") final.Bulb.Locations.OFB6a <- temp temp <- Total.Bulb.Bins.PD52 new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.PD52",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_PD52.txt",sep="\t") final.Bulb.Locations.PD52 <- temp temp <- Total.Bulb.Bins.PD56 new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.PD56",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_PD56.txt",sep="\t") final.Bulb.Locations.PD56 <- temp temp <- Total.Bulb.Bins.PD58 new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.PD58",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_PD58.txt",sep="\t") final.Bulb.Locations.PD58 <- temp temp <- Total.Bulb.Bins.PD77 new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.PD77",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_PD77.txt",sep="\t") final.Bulb.Locations.PD77 <- temp temp <- Total.Bulb.Bins.PD79 new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Total.Bulb.Bins.PD79",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(temp)[[1]] <- new.pos write.table(temp,"Bulb_Locations_PD79.txt",sep="\t") final.Bulb.Locations.PD79 <- temp ################################################################################# # Standardize Image File Names ################################################################################# # AZ_109_146 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/AZ_109_146") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") # AZ_251_146 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/AZ_251_146") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") # AZ_84_145 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/AZ_84_145") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") # AZ_90_242 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/AZ_90_242") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") # AZ_99_140 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/AZ_99_140") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") # Control_H190_260 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/Control_H190_260") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") # Control_H250_185 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/NewH250") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MAP2*.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *HEAVY*.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *S100*.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") # Control_OFB57_194 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/Control_OFB57_194") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") # Control_OFB6A_107 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/Control_OFB6A_107") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") # PD_52_247 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/PD_52_247") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") # PD_56_236 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/PD_56_236") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") # PD_58_229 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/PD_58_229") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") # PD_77_197 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/PD_77_197") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") # PD_79_201 setwd("/data/johnsonko/SideProject/Helen/20200811/Starting_Images/PD_79_201") system("mv *SYNUCLEIN.jpg ALPHA_SYNUCLEIN.jpg") system("mv *_BETA*.jpg BETA_AMYLOID.jpg") system("mv *CALBINDIN.jpg CALBINDIN.jpg") system("mv *CD31.jpg CD31.jpg") system("mv *CH*NEUN.jpg CH_NEUN.jpg") system("mv *_CNPASE.jpg CNPASE.jpg") system("mv *CNPase.jpg CNPASE.jpg") system("mv *_COLLAGEN*.jpg COLLAGEN_IV.jpg") system("mv *_DAPI.jpg DAPI.jpg") system("mv *GFAP.jpg GFAP.jpg") system("mv *_HISTONES.jpg HISTONES.jpg") system("mv *_HLADR.jpg HLADR.jpg") system("mv *_IBA1.jpg IBA1.jpg") system("mv *_MAP2.jpg MAP2.jpg") system("mv *MYELIN*.jpg MBP.jpg") system("mv *MBP*.jpg MBP.jpg") system("mv *NEUROFILAMENT*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEUROFILAMENT*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *NFL*.jpg NEURO_LIGHT.jpg") system("mv *NFH*.jpg NEURO_HEAVY.jpg") system("mv *NEURO*LIGHT.jpg NEURO_LIGHT.jpg") system("mv *NEURO*HEAVY.jpg NEURO_HEAVY.jpg") system("mv *_OMP.jpg OMP.jpg") system("mv *_PGP9*.jpg PGP9_5.jpg") system("mv *CALRETININ.jpg RB_CALRETININ.jpg") system("mv *_S100.jpg S100.jpg") system("mv *_SYNAPTOPHYSIN.jpg SYNAPTOPHYSIN.jpg") system("mv *TAU*.jpg TAU.jpg") system("mv *_TOMATO*.jpg TOMATO_LECTIN.jpg") system("mv *HYDROXYLASE.jpg TYR_HYDROXYLASE.jpg") system("mv *_UEA*.jpg UEA_LECTIN.jpg") ################################################################################# # Generate Label Counts ################################################################################# # AZ_109_146 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/AZ_109_146") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(temp.dir,"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } # AZ_251_146 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/AZ_251_146") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(getwd(),"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } # AZ_84_145 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/AZ_84_145") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(getwd(),"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } # AZ_90_242 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/AZ_90_242") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(getwd(),"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } # AZ_99_140 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/AZ_99_140") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(getwd(),"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } # Control_H190_260 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/Control_H190_260") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(getwd(),"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } # Control_OFB57_194 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/Control_OFB57_194") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(getwd(),"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } # PD_52_247 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/PD_52_247") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(getwd(),"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } # PD_56_236 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/PD_56_236") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(getwd(),"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } # PD_58_229 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/PD_58_229") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(getwd(),"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } # PD_77_197 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/PD_77_197") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(getwd(),"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } # PD_79_201 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/PD_79_201") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(getwd(),"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } # Control_H250_185 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/NewH250") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(getwd(),"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } # Control_OFB6A_107 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/Control_OFB6A_107") temp.dir <- getwd() fff.in <- system2("ls",stdout=TRUE) fff.out <- str_replace(fff.in,".jpg",".txt") for (i in 1:length(fff.out)) { fff.out[i] <- paste(c("counts_",fff.out[i]),collapse="",sep="") } for (i in 1:length(fff.in)) { print(i) ipath <- paste(c(getwd(),"/",fff.in[i]),collapse="",sep="") working.im <- load.image(ipath) working.im <- grayscale(working.im) working.im.min.x <- 0 working.im.max.x <- dim(working.im)[1] working.im.min.y <- 0 working.im.max.y <- dim(working.im)[2] bin.size <- 31 x.pos <- working.im.min.x finito.x <- 0 temp.out <- t(data.table(c(rep(" ",5)))) write.table(temp.out,fff.in[i],row.names=FALSE,col.names=FALSE,append=FALSE,sep="\t",eol="\n") while (finito.x==0) { tempx1 <- x.pos tempx2 <- x.pos+bin.size if(tempx2>working.im.max.x) { tempx2 <- working.im.max.x finito.x <- 1 } y.pos <- working.im.min.y finito.y <- 0 while (finito.y==0) { tempy1 <- y.pos tempy2 <- y.pos+bin.size if(tempy2>working.im.max.y) { tempy2 <- working.im.max.y finito.y <- 1 } temp.grab <- working.im[c(tempx1:tempx2),c(tempy1:tempy2),1,1] temp.grab <- as.numeric(unlist(temp.grab)) temp.grab <- ifelse(is.na(temp.grab),0,temp.grab) temp.grab.median <- median(temp.grab) temp.out <- t(data.table(c(tempx1,tempx2,tempy1,tempy2,temp.grab.median))) write.table(temp.out,fff.out[i],row.names=FALSE,col.names=FALSE,append=TRUE,sep="\t",eol="\n") y.pos <- tempy2 } x.pos <- tempx2 } } ############################################################# # Collapse Label Counts into Label Matrix ############################################################# setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/AZ_109_146") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("AZ_109_146",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_AZ_109_146.txt",sep="\t") setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/AZ_251_146") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("AZ_251_146",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_AZ_251_146.txt",sep="\t") setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/AZ_84_145") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("AZ_84_145",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_AZ_84_145.txt",sep="\t") setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/AZ_90_242") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("AZ_90_242",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_AZ_90_242.txt",sep="\t") setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/AZ_99_140") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("AZ_99_140",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_AZ_99_140.txt",sep="\t") setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/Control_H190_260") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Control_H190_260",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_Control_H190_260.txt",sep="\t") setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/NewH250") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Control_H250_185",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_Control_H250_185.txt",sep="\t") setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/Control_OFB57_194") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Control_OFB57_194",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_Control_OFB57_194.txt",sep="\t") setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/Control_OFB6A_107") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("Control_OFB6A_107",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_Control_OFB6A_107.txt",sep="\t") setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/PD_52_247") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("PD_52_247",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_PD_52_247.txt",sep="\t") setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/PD_56_236") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("PD_56_236",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_PD_56_236.txt",sep="\t") setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/PD_58_229") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("PD_58_229",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_PD_58_229.txt",sep="\t") setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/PD_77_197") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("PD_77_197",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_PD_77_197.txt",sep="\t") setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Counts/PD_79_201") fff.in <- dir() working.in <- NULL for(i in 1:length(fff.in)) { print(i) temp <- read.table(fff.in[i]) temp0 <- temp[,5] working.in <- cbind(working.in,temp0) } fff.names <- str_replace(fff.in,".txt","") fff.names <- str_replace(fff.names,"counts_","") dimnames(working.in)[[2]] <- fff.names new.x <- apply(temp[,c(1:2)],1,median) new.y <- apply(temp[,c(3:4)],1,median) new.pos <- apply(cbind(new.x,new.y),1,paste,collapse="X",sep="") new.pos <- apply(cbind(rep("PD_79_201",length(new.pos)),new.pos),1,paste,collapse="@",sep="") dimnames(working.in)[[1]] <- new.pos write.table(working.in,"Collapsed_Counts_PD_79_201.txt",sep="\t") ############################################################# # Intersect Label Matrix with Bulb Locations ############################################################# setwd("/data/johnsonko/SideProject/Helen/20200811/Bulb_Locations") final.Bulb.Locations.AZ109 <- read.table("Bulb_Locations_AZ109.txt") # AZ_109_146 final.Bulb.Locations.AZ84 <- read.table("Bulb_Locations_AZ84.txt") # AZ_84_145 final.Bulb.Locations.AZ90 <- read.table("Bulb_Locations_AZ90.txt") # AZ_90_242 final.Bulb.Locations.AZ99 <- read.table("Bulb_Locations_AZ99.txt") # AZ_99_140 final.Bulb.Locations.H190 <- read.table("Bulb_Locations_H190.txt") # Control_H190_260 final.Bulb.Locations.H250 <- read.table("Bulb_Locations_H250.txt") # Control_H250_185 final.Bulb.Locations.H251 <- read.table("Bulb_Locations_H251.txt") # AZ_251_146 final.Bulb.Locations.OFB57 <- read.table("Bulb_Locations_OFB57.txt") # Control_OFB57_194 final.Bulb.Locations.OFB6a <- read.table("Bulb_Locations_OFB6a.txt") # Control_OFB6A_107 final.Bulb.Locations.PD52 <- read.table("Bulb_Locations_PD52.txt") # PD_52_247 final.Bulb.Locations.PD56 <- read.table("Bulb_Locations_PD56.txt") # PD_56_236 final.Bulb.Locations.PD58 <- read.table("Bulb_Locations_PD58.txt") # PD_58_22 final.Bulb.Locations.PD77 <- read.table("Bulb_Locations_PD77.txt") # PD_77_197 final.Bulb.Locations.PD79 <- read.table("Bulb_Locations_PD79.txt") # PD_79_201 setwd("/data/johnsonko/SideProject/Helen/20200811/Label_Collapsed") Collapsed_Counts_AZ_109_146 <- read.table("Collapsed_Counts_AZ_109_146.txt") Collapsed_Counts_AZ_251_146 <- read.table("Collapsed_Counts_AZ_251_146.txt") Collapsed_Counts_AZ_84_145 <- read.table("Collapsed_Counts_AZ_84_145.txt") Collapsed_Counts_AZ_90_242 <- read.table("Collapsed_Counts_AZ_90_242.txt") Collapsed_Counts_AZ_99_140 <- read.table("Collapsed_Counts_AZ_99_140.txt") Collapsed_Counts_Control_H190_260 <- read.table("Collapsed_Counts_Control_H190_260.txt") Collapsed_Counts_Control_H250_185 <- read.table("Collapsed_Counts_Control_H250_185.txt") Collapsed_Counts_Control_OFB57_194 <- read.table("Collapsed_Counts_Control_OFB57_194.txt") Collapsed_Counts_Control_OFB6A_107 <- read.table("Collapsed_Counts_Control_OFB6A_107.txt") Collapsed_Counts_PD_52_247 <- read.table("Collapsed_Counts_PD_52_247.txt") Collapsed_Counts_PD_56_236 <- read.table("Collapsed_Counts_PD_56_236.txt") Collapsed_Counts_PD_58_229 <- read.table("Collapsed_Counts_PD_58_229.txt") Collapsed_Counts_PD_77_197 <- read.table("Collapsed_Counts_PD_77_197.txt") Collapsed_Counts_PD_79_201 <- read.table("Collapsed_Counts_PD_79_201.txt") setwd("/data/johnsonko/SideProject/Helen/20200811/Analysis_Ready") # AZ_109_146 tempa <- Collapsed_Counts_AZ_109_146 tempb <- final.Bulb.Locations.AZ109 tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_AZ_109_146 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_AZ_109_146,"Final_Analysis_Ready_Counts_AZ_109_146.txt",sep="\t") # AZ_251_146 tempa <- Collapsed_Counts_AZ_251_146 tempb <- final.Bulb.Locations.H251 tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_AZ_251_146 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_AZ_251_146,"Final_Analysis_Ready_Counts_AZ_251_146.txt",sep="\t") # AZ_84_145 tempa <- Collapsed_Counts_AZ_84_145 tempb <- final.Bulb.Locations.AZ84 tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_AZ_84_145 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_AZ_84_145,"Final_Analysis_Ready_Counts_AZ_84_145.txt",sep="\t") # AZ_90_242 tempa <- Collapsed_Counts_AZ_90_242 tempb <- final.Bulb.Locations.AZ90 tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_AZ_90_242 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_AZ_90_242,"Final_Analysis_Ready_Counts_AZ_90_242.txt",sep="\t") # AZ_99_140 tempa <- Collapsed_Counts_AZ_99_140 tempb <- final.Bulb.Locations.AZ99 tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_AZ_99_140 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_AZ_99_140,"Final_Analysis_Ready_Counts_AZ_99_140.txt",sep="\t") # Control_H190_260 tempa <- Collapsed_Counts_Control_H190_260 tempb <- final.Bulb.Locations.H190 tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_Control_H190_260 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_Control_H190_260,"Final_Analysis_Ready_Counts_Control_H190_260.txt",sep="\t") # Control_H250_185 tempa <- Collapsed_Counts_Control_H250_185 tempb <- final.Bulb.Locations.H250 tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_Control_H250_185 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_Control_H250_185,"Final_Analysis_Ready_Counts_Control_H250_185.txt",sep="\t") # Control_OFB57_194 tempa <- Collapsed_Counts_Control_OFB57_194 tempb <- final.Bulb.Locations.OFB57 tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_Control_OFB57_194 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_Control_OFB57_194,"Final_Analysis_Ready_Counts_Control_OFB57_194.txt",sep="\t") # Control_OFB6A_107 tempa <- Collapsed_Counts_Control_OFB6A_107 tempb <- final.Bulb.Locations.OFB6a tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_Control_OFB6A_107 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_Control_OFB6A_107,"Final_Analysis_Ready_Counts_Control_OFB6A_107.txt",sep="\t") # PD_52_247 tempa <- Collapsed_Counts_PD_52_247 tempb <- final.Bulb.Locations.PD52 tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_PD_52_247 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_PD_52_247,"Final_Analysis_Ready_Counts_PD_52_247.txt",sep="\t") # PD_56_236 tempa <- Collapsed_Counts_PD_56_236 tempb <- final.Bulb.Locations.PD56 tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_PD_56_236 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_PD_56_236,"Final_Analysis_Ready_Counts_PD_56_236.txt",sep="\t") # PD_58_22 tempa <- Collapsed_Counts_PD_58_229 tempb <- final.Bulb.Locations.PD58 tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_PD_58_229 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_PD_58_229,"Final_Analysis_Ready_Counts_PD_58_229.txt",sep="\t") # PD_77_197 tempa <- Collapsed_Counts_PD_77_197 tempb <- final.Bulb.Locations.PD77 tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_PD_77_197 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_PD_77_197,"Final_Analysis_Ready_Counts_PD_77_197.txt",sep="\t") # PD_79_201 tempa <- Collapsed_Counts_PD_79_201 tempb <- final.Bulb.Locations.PD79 tempaa <- dimnames(tempa)[[1]] tempaaa <- str_replace_all(tempaa,"^.+@","") dimnames(tempa)[[1]] <- tempaaa length(tempaaa) tempbb <- dimnames(tempb)[[1]] tempbbb <- str_replace_all(tempbb,"^.+@","") length(tempbbb) temp1 <- intersect(tempaaa,tempbbb) length(temp1) Final_Analysis_Ready_Counts_PD_79_201 <- tempa[temp1,] write.table(Final_Analysis_Ready_Counts_PD_79_201,"Final_Analysis_Ready_Counts_PD_79_201.txt",sep="\t") ############################################################# # Cross label Poisson Crunch # https://protect-au.mimecast.com/s/E2X4CMwGq5hkOrYgcNe4Qk?domain=dataquest.io ############################################################# setwd("/data/johnsonko/SideProject/Helen/20200811/Analysis_Ready") Final_Analysis_Ready_Counts_AZ_109_146 <- read.table("Final_Analysis_Ready_Counts_AZ_109_146.txt",header=T) Final_Analysis_Ready_Counts_AZ_251_146 <- read.table("Final_Analysis_Ready_Counts_AZ_251_146.txt",header=T) Final_Analysis_Ready_Counts_AZ_84_145 <- read.table("Final_Analysis_Ready_Counts_AZ_84_145.txt",header=T) Final_Analysis_Ready_Counts_AZ_90_242 <- read.table("Final_Analysis_Ready_Counts_AZ_90_242.txt",header=T) Final_Analysis_Ready_Counts_AZ_99_140 <- read.table("Final_Analysis_Ready_Counts_AZ_99_140.txt",header=T) Final_Analysis_Ready_Counts_Control_H190_260 <- read.table("Final_Analysis_Ready_Counts_Control_H190_260.txt",header=T) Final_Analysis_Ready_Counts_Control_H250_185 <- read.table("Final_Analysis_Ready_Counts_Control_H250_185.txt",header=T) Final_Analysis_Ready_Counts_Control_OFB57_194 <- read.table("Final_Analysis_Ready_Counts_Control_OFB57_194.txt",header=T) Final_Analysis_Ready_Counts_Control_OFB6A_107 <- read.table("Final_Analysis_Ready_Counts_Control_OFB6A_107.txt",header=T) Final_Analysis_Ready_Counts_PD_52_247 <- read.table("Final_Analysis_Ready_Counts_PD_52_247.txt",header=T) Final_Analysis_Ready_Counts_PD_56_236 <- read.table("Final_Analysis_Ready_Counts_PD_56_236.txt",header=T) Final_Analysis_Ready_Counts_PD_58_229 <- read.table("Final_Analysis_Ready_Counts_PD_58_229.txt",header=T) Final_Analysis_Ready_Counts_PD_77_197 <- read.table("Final_Analysis_Ready_Counts_PD_77_197.txt",header=T) Final_Analysis_Ready_Counts_PD_79_201 <- read.table("Final_Analysis_Ready_Counts_PD_79_201.txt",header=T) setwd("/data/johnsonko/SideProject/Helen/20200811/Analysis_Slides") ttt <- c("Final_Analysis_Ready_Counts_AZ_109_146", "Final_Analysis_Ready_Counts_AZ_251_146", "Final_Analysis_Ready_Counts_AZ_84_145", "Final_Analysis_Ready_Counts_AZ_90_242", "Final_Analysis_Ready_Counts_AZ_99_140", "Final_Analysis_Ready_Counts_Control_H190_260", "Final_Analysis_Ready_Counts_Control_H250_185", "Final_Analysis_Ready_Counts_Control_OFB57_194", "Final_Analysis_Ready_Counts_Control_OFB6A_107", "Final_Analysis_Ready_Counts_PD_52_247", "Final_Analysis_Ready_Counts_PD_56_236", "Final_Analysis_Ready_Counts_PD_58_229", "Final_Analysis_Ready_Counts_PD_77_197", "Final_Analysis_Ready_Counts_PD_79_201") tttppp <- c("Reconstructed_Slide_For_AZ_109_146.pdf", "Reconstructed_Slide_For_AZ_251_146.pdf", "Reconstructed_Slide_For_AZ_84_145.pdf", "Reconstructed_Slide_For_AZ_90_242.pdf", "Reconstructed_Slide_For_AZ_99_140.pdf", "Reconstructed_Slide_For_Control_H190_260.pdf", "Reconstructed_Slide_For_Control_H250_185.pdf", "Reconstructed_Slide_For_Control_OFB57_194.pdf", "Reconstructed_Slide_For_Control_OFB6A_107.pdf", "Reconstructed_Slide_For_PD_52_247.pdf", "Reconstructed_Slide_For_PD_56_236.pdf", "Reconstructed_Slide_For_PD_58_229.pdf", "Reconstructed_Slide_For_PD_77_197.pdf", "Reconstructed_Slide_For_PD_79_201.pdf") running.bin.tally <- NULL p.cut.off.to.use <- 0.05 for (t in 1:length(ttt)) { print(t) temp0 <- eval(parse(text=ttt[t])) temp0 <- as.matrix(temp0) temp0 <- round(temp0*100,0) temp1 <- ifelse(temp0==0,NA,temp0) temp2 <- as.numeric(unlist(temp1)) temp3 <- temp2[!is.na(temp2)] temp4 <- density(temp3) pdf(tttppp[t],width = 28950/1000, height = 6030/1000) plot(temp4,type='l',main="Cross-Label Distribution",xlab="Intensity",ylab="Frequency") temp5 <- round(mean(temp3,trim=0.95),0) temp6 <- max(temp3) temp7 <- c(0:temp6) temp8 <- dpois(temp7, temp5) lines(temp8,col=2,type='l') abline(v=qpois(p.cut.off.to.use,temp5,lower.tail=FALSE),col=2,lty=2) legend("topright", title="Legend",c("Actual","Poisson","Pr(<0.05)"), col=c("black","red","red"), horiz=TRUE, cex=0.8, lty=c(1,1,2)) temp9 <- ppois((temp1-1), temp5, lower.tail = FALSE) temp10 <- ifelse(temp90) { temp111 <- names(temp99) temp100 <- NULL for (j in 1:length(temp111)) { temp122 <- strsplit(temp111[j], "X")[[1]] temp100 <- rbind(temp100,as.numeric(temp122)) } newnew.x <- as.numeric(temp100[,1]) newnew.y <- as.numeric(temp100[,2]) points(as.numeric(newnew.x),-1*as.numeric(newnew.y),cex=1,pch=15,col=col.2.use[i]) } } dev.off() running.bin.tally <- cbind(running.bin.tally,temp11) } dimnames(running.bin.tally)[[1]] <- dimnames(temp0)[[2]] dimnames(running.bin.tally)[[2]] <- c("AZ_109_146", "AZ_251_146", "AZ_84_145", "AZ_90_242", "AZ_99_140", "Control_H190_260", "Control_H250_185", "Control_OFB57_194", "Control_OFB6A_107", "PD_52_247", "PD_56_236", "PD_58_229", "PD_77_197", "PD_79_201") original.running.bin.tally <- running.bin.tally running.bin.tally <- rbind(c(dim(final.Bulb.Locations.AZ109)[1], dim(final.Bulb.Locations.H251)[1], dim(final.Bulb.Locations.AZ84)[1], dim(final.Bulb.Locations.AZ90)[1], dim(final.Bulb.Locations.AZ99)[1], dim(final.Bulb.Locations.H190)[1], dim(final.Bulb.Locations.H250)[1], dim(final.Bulb.Locations.OFB57)[1], dim(final.Bulb.Locations.OFB6a)[1], dim(final.Bulb.Locations.PD52)[1], dim(final.Bulb.Locations.PD56)[1], dim(final.Bulb.Locations.PD58)[1], dim(final.Bulb.Locations.PD77)[1], dim(final.Bulb.Locations.PD79)[1]),running.bin.tally) dimnames(running.bin.tally)[[1]][1] <- "Bulb_Counts" setwd("/data/johnsonko/SideProject/Helen/20200811/Analysis_Results") write.table(running.bin.tally,"running.bin.tally.txt",sep="\t") running.bin.tally <- read.table("running.bin.tally.txt",header=T,row.names=1) ############################################################# # Test Bin Counts ############################################################# running.tally <- running.bin.tally ratio.tally <- running.tally for (i in 1:dim(running.tally)[2]) { temp1 <- running.tally[,i] temp2 <- temp1[1] temp3 <- temp1/temp2 ratio.tally[,i] <- temp3 } ratio.tally <- ratio.tally[-c(1),] ratio.tally <- as.matrix(ratio.tally) write.table(ratio.tally,"ratio.tally.txt",sep="\t") ratio.tally <- read.table("ratio.tally.txt",header=T,row.names=1) ratio.tally <- as.matrix(ratio.tally) library(gplots) library(ggplot2) tiff("Clustered_HeatMap_PreTesting.tiff",width = 8, height = 8, units = "in", res=300) cc <- greenred(64) hhh <- heatmap.2(ratio.tally,trace="none",density.info="none",col=cc,labRow=dimnames(ratio.tally)[[1]],labCol=dimnames(ratio.tally)[[2]],scale="none",mar=c(10,10)) dev.off() tiff("PCA_PreTesting.tiff",width = 8, height = 8, units = "in", res=300) col.2.use <- c(rep("red",5),rep("green",4),rep("blue",5)) pca.results <- prcomp(t(ratio.tally)) totalvar <- (pca.results[[1]]^2) variancePer <- round(totalvar/sum(totalvar)*100,1) variancePer <- variancePer[1:3] pca.x <- pca.results$x[,c(1:3)] palette("default") x.range <- range(pca.x[,1]) y.range <- range(pca.x[,2]) xlab <- paste(c("Principal Component 1 (",variancePer[1],"%)"),collapse="") ylab <- paste(c("Principal Component 2 (",variancePer[2],"%)"),collapse="") plot(pca.x[,1],pca.x[,2],xlab=xlab,ylab=ylab,type='n') points(pca.x[,1],pca.x[,2],lwd=0.5,col=col.2.use,cex=2,pch=19) points(pca.x[,1],pca.x[,2],lwd=0.5,col=1,cex=2,pch=21) legend("topright", title="Legend",c("AZ","Control","PD"), col=c("red","green","blue"), horiz=TRUE, cex=0.8, pch = 19) dev.off() #------------------------------------------------------------------------------- # ANOVA #------------------------------------------------------------------------------- library(car) Final.working.data <- ratio.tally ggg <- c(rep("AZ",5),rep("Control",4),rep("PD",5)) running.pvs <- NULL for (i in 1:dim(Final.working.data)[1]) { print(i) probe.data <- as.numeric(unlist(Final.working.data[i,])) temp <- data.frame(DATA=probe.data,GROUP=factor(ggg)) aov.results <- aov(DATA~GROUP,data=temp) if (deviance(aov.results ) > sqrt(.Machine$double.eps)) { temp <- Anova(aov.results,type="III",singular.ok=TRUE) temp <- summary(aov.results) temp <- as.numeric(unlist(temp))[9] running.pvs <- c(running.pvs,temp) } else { running.pvs <- c(running.pvs,1) } } names(running.pvs) <- dimnames(Final.working.data)[[1]] #------------------------------------------------------------------------------- # FDR MCC (alpha=0.05) #------------------------------------------------------------------------------- library("multtest") temp1 <- mt.rawp2adjp(running.pvs, proc="BH") temp2 <- temp1$adj[order(temp1$index),] temp2 <- as.data.frame(temp2) dimnames(temp2)[[1]] <- names(running.pvs) write.table(temp2,"ANOVA_Results.txt",sep="\t",row.names=T) #------------------------------------------------------------------------------- # Perform Pos-Hoc Testing #------------------------------------------------------------------------------- posthoc.data <- Final.working.data running.posthoc <- NULL running.diffs <- NULL for (i in 1:dim(posthoc.data)[1]) { print(i) print(dim(posthoc.data)[1]) temp1 <- as.numeric(posthoc.data[i,]) temp2 <- data.frame(DATA=temp1,Class=ggg) temp3 <- aov(DATA~Class,data=temp2) temp4 <- TukeyHSD(temp3) temp5 <- temp4[[1]] temp6 <- temp5[,4] running.posthoc <- rbind(running.posthoc,temp6) temp7 <- temp5[,1] running.diffs <- rbind(running.diffs,temp7) } running.posthoc <- as.data.frame(running.posthoc) dimnames(running.posthoc)[[1]] <- dimnames(posthoc.data)[[1]] write.table(running.posthoc,"PostHoc_Results.txt",sep="\t",row.names=T) dd <- Final.working.data temp0 <- dd[,c(1:5)] AZ.mean <- apply(temp0,1,mean) AZ.sd <- apply(temp0,1,sd) temp0 <- dd[,c(6:9)] Control.mean <- apply(temp0,1,mean) Control.sd <- apply(temp0,1,sd) temp0 <- dd[,c(10:14)] PD.mean <- apply(temp0,1,mean) PD.sd <- apply(temp0,1,sd) cx.out <- cbind(Control.mean,Control.sd,AZ.mean,AZ.sd,PD.mean,PD.sd) write.table(cx.out,"Mean_SD_Results.txt",sep="\t",row.names=T) # Post testing plots fff <- ratio.tally[c(2,9,13,19,20,21,22,24),] tiff("Clustered_HeatMap_PostTesting.tiff",width = 8, height = 8, units = "in", res=300) cc <- greenred(64) cc <- colorpanel(64, "blue", "white","red") hhh <- heatmap.2(fff,trace="none",density.info="none",col=cc,Colv=FALSE,dendrogram="row",labRow=dimnames(fff)[[1]],labCol=dimnames(fff)[[2]],scale="row",mar=c(10,15)) dev.off() tiff("dendrogram_20201207.tiff",width = 8, height = 5, res=300, units = "in") pheatmap::pheatmap(fff, cluster_rows=TRUE, cluster_cols=FALSE, scale="row", fontsize=12) dev.off() # https://protect-au.mimecast.com/s/qyCHCNLJr5tPlWpAilslQA?domain=cran.r-project.org library(cluster) tiff("PCA_PostTesting.tiff",width = 8, height = 8, units = "in", res=300) col.2.use <- c(rep("red",5),rep("green",4),rep("blue",5)) pca.results <- prcomp(t(fff)) totalvar <- (pca.results[[1]]^2) variancePer <- round(totalvar/sum(totalvar)*100,1) variancePer <- variancePer[1:3] pca.x <- pca.results$x[,c(1:3)] palette("default") x.range <- range(pca.x[,1]) y.range <- range(pca.x[,2]) xlab <- paste(c("Principal Component 1 (",variancePer[1],"%)"),collapse="") ylab <- paste(c("Principal Component 2 (",variancePer[2],"%)"),collapse="") plot(pca.x[,1],pca.x[,2],xlab=xlab,ylab=ylab,type='n') points(pca.x[,1],pca.x[,2],lwd=0.5,col=col.2.use,cex=2,pch=19) points(pca.x[,1],pca.x[,2],lwd=0.5,col=1,cex=2,pch=21) legend("top", title="Legend",c("AZ","Control","PD"), col=c("red","green","blue"), horiz=TRUE, cex=0.8, pch = 19) dev.off() ddd <- c(rep("AZ",5),rep("Control",4),rep("PD",5)) ddd <- as.data.frame(ddd) dimnames(ddd)[[2]][1] <- "Legend" tiff("PCA_No_Ellipses_20201207.tiff",width = 8, height = 8, units = "in", res=300) autoplot(pca.results,data=ddd,colour='Legend',size=4) dev.off() tiff("PCA_With_Ellipses_20201207.tiff",width = 8, height = 8, units = "in", res=300) autoplot(pca.results,data=ddd,colour='Legend',size=4,frame = TRUE, frame.type = 'norm') dev.off() https://protect-au.mimecast.com/s/lCCiCOMKv5hZR8kJuRSZ06?domain=stackoverflow.com library(gmodels) az.stats <- apply(fff[,(1:5)],1,ci) control.stats <- apply(fff[,(6:9)],1,ci) pd.stats <- apply(fff[,(10:14)],1,ci) dd.stats <- rbind(az.stats[1,],control.stats[1,],pd.stats[1,]) dimnames(dd.stats)[[1]] <- c("AZ","Control","PD") ci.l.stats <- rbind(az.stats[2,],control.stats[2,],pd.stats[2,]) dimnames(ci.l.stats)[[1]] <- c("AZ","Control","PD") ci.l.stats <- ifelse(ci.l.stats<0,0,ci.l.stats) ci.u.stats <- rbind(az.stats[3,],control.stats[3,],pd.stats[3,]) dimnames(ci.u.stats)[[1]] <- c("AZ","Control","PD") mp <- barplot2(dd.stats, beside = TRUE, col = c("red","green","blue"), legend = rownames(dd.stats), ylim = c(0, 1), plot.ci = TRUE, ci.l = ci.l.stats, ci.u = ci.u.stats ) ci.u <- ci.u.stats y.cord <- rbind(c(ci.u[1,]+1),c(apply(ci.u,2,max)+5), c(apply(ci.u,2,max)+5),c(ci.u[2,]+1)) x.cord <- apply(mp,2,function(x) rep(x,each=2)) sapply(1:5,function(x) lines(x.cord[,x],y.cord[,x])) https://protect-au.mimecast.com/s/5zj8CP7Lw5FNGwnOF96uNR?domain=ncbi.nlm.nih.gov final.ci.l <- NULL for(i in 1:dim(ci.l.stats)[2]) { final.ci.l <- c(final.ci.l,ci.l.stats[,i]) } final.ci.l <- ifelse(final.ci.l<0,0,final.ci.l) ci.u.stats <- rbind(az.stats[3,],control.stats[3,],pd.stats[3,]) final.ci.u <- NULL for(i in 1:dim(ci.u.stats)[2]) { final.ci.u <- c(final.ci.u,ci.u.stats[,i]) } final.ci.u <- ifelse(final.ci.u>1,1,final.ci.u) , plot.ci = TRUE, ci.l = ci.l, ci.u = ci.u) mybarcol <- c("red","green","blue") hh <- t(VADeaths)[1:2, 5:1] mybarcol <- "gray20" ci.l <- hh * 0.85 ci.u <- hh * 1.15 mp <- barplot2(hh, beside = TRUE, col = c("grey12", "grey82"), legend = colnames(VADeaths)[1:2], ylim = c(0, 100), cex.names = 1.5, plot.ci = TRUE, ci.l = ci.l, ci.u = ci.u) ############################################################# # Perform Clustering ############################################################# setwd("/data/johnsonko/SideProject/Helen/20200811/Bulb_Locations") final.Bulb.Locations.AZ109 <- read.table("Bulb_Locations_AZ109.txt") # AZ_109_146 final.Bulb.Locations.AZ84 <- read.table("Bulb_Locations_AZ84.txt") # AZ_84_145 final.Bulb.Locations.AZ90 <- read.table("Bulb_Locations_AZ90.txt") # AZ_90_242 final.Bulb.Locations.AZ99 <- read.table("Bulb_Locations_AZ99.txt") # AZ_99_140 final.Bulb.Locations.H190 <- read.table("Bulb_Locations_H190.txt") # Control_H190_260 final.Bulb.Locations.H250 <- read.table("Bulb_Locations_H250.txt") # Control_H250_185 final.Bulb.Locations.H251 <- read.table("Bulb_Locations_H251.txt") # AZ_251_146 final.Bulb.Locations.OFB57 <- read.table("Bulb_Locations_OFB57.txt") # Control_OFB57_194 final.Bulb.Locations.OFB6a <- read.table("Bulb_Locations_OFB6a.txt") # Control_OFB6A_107 final.Bulb.Locations.PD52 <- read.table("Bulb_Locations_PD52.txt") # PD_52_247 final.Bulb.Locations.PD56 <- read.table("Bulb_Locations_PD56.txt") # PD_56_236 final.Bulb.Locations.PD58 <- read.table("Bulb_Locations_PD58.txt") # PD_58_22 final.Bulb.Locations.PD77 <- read.table("Bulb_Locations_PD77.txt") # PD_77_197 final.Bulb.Locations.PD79 <- read.table("Bulb_Locations_PD79.txt") # PD_79_201 setwd("/data/johnsonko/SideProject/Helen/20200811/Analysis_Ready") Final_Analysis_Ready_Counts_AZ_109_146 <- read.table("Final_Analysis_Ready_Counts_AZ_109_146.txt",header=T) Final_Analysis_Ready_Counts_AZ_251_146 <- read.table("Final_Analysis_Ready_Counts_AZ_251_146.txt",header=T) Final_Analysis_Ready_Counts_AZ_84_145 <- read.table("Final_Analysis_Ready_Counts_AZ_84_145.txt",header=T) Final_Analysis_Ready_Counts_AZ_90_242 <- read.table("Final_Analysis_Ready_Counts_AZ_90_242.txt",header=T) Final_Analysis_Ready_Counts_AZ_99_140 <- read.table("Final_Analysis_Ready_Counts_AZ_99_140.txt",header=T) Final_Analysis_Ready_Counts_Control_H190_260 <- read.table("Final_Analysis_Ready_Counts_Control_H190_260.txt",header=T) Final_Analysis_Ready_Counts_Control_H250_185 <- read.table("Final_Analysis_Ready_Counts_Control_H250_185.txt",header=T) Final_Analysis_Ready_Counts_Control_OFB57_194 <- read.table("Final_Analysis_Ready_Counts_Control_OFB57_194.txt",header=T) Final_Analysis_Ready_Counts_Control_OFB6A_107 <- read.table("Final_Analysis_Ready_Counts_Control_OFB6A_107.txt",header=T) Final_Analysis_Ready_Counts_PD_52_247 <- read.table("Final_Analysis_Ready_Counts_PD_52_247.txt",header=T) Final_Analysis_Ready_Counts_PD_56_236 <- read.table("Final_Analysis_Ready_Counts_PD_56_236.txt",header=T) Final_Analysis_Ready_Counts_PD_58_229 <- read.table("Final_Analysis_Ready_Counts_PD_58_229.txt",header=T) Final_Analysis_Ready_Counts_PD_77_197 <- read.table("Final_Analysis_Ready_Counts_PD_77_197.txt",header=T) Final_Analysis_Ready_Counts_PD_79_201 <- read.table("Final_Analysis_Ready_Counts_PD_79_201.txt",header=T) ttt <- c("Final_Analysis_Ready_Counts_AZ_109_146", "Final_Analysis_Ready_Counts_AZ_251_146", "Final_Analysis_Ready_Counts_AZ_84_145", "Final_Analysis_Ready_Counts_AZ_90_242", "Final_Analysis_Ready_Counts_AZ_99_140", "Final_Analysis_Ready_Counts_Control_H190_260", "Final_Analysis_Ready_Counts_Control_H250_185", "Final_Analysis_Ready_Counts_Control_OFB57_194", "Final_Analysis_Ready_Counts_Control_OFB6A_107", "Final_Analysis_Ready_Counts_PD_52_247", "Final_Analysis_Ready_Counts_PD_56_236", "Final_Analysis_Ready_Counts_PD_58_229", "Final_Analysis_Ready_Counts_PD_77_197", "Final_Analysis_Ready_Counts_PD_79_201") p.cut.off.to.use <- 0.05 size.2.use <- NULL for (t in 1:length(ttt)) { print(t) temp0 <- eval(parse(text=ttt[t])) print(dim(temp0)) temp0 <- as.matrix(temp0) temp0 <- round(temp0*100,0) temp1 <- ifelse(temp0==0,NA,temp0) temp2 <- as.numeric(unlist(temp1)) temp3 <- temp2[!is.na(temp2)] temp4 <- density(temp3) temp5 <- round(mean(temp3,trim=0.95),0) temp6 <- max(temp3) temp7 <- c(0:temp6) temp8 <- dpois(temp7, temp5) temp9 <- ppois((temp1-1), temp5, lower.tail = FALSE) temp10 <- ifelse(is.na(temp9),1,temp9) temp11 <- ifelse(temp100 temp13 <- temp11[temp12,] size.2.use <- c(size.2.use,dim(temp13)[1]) } size.2.use <- round(size.2.use/size.2.use[1]) size.2.use ensure.order <- dimnames(Final_Analysis_Ready_Counts_AZ_109_146)[[2]] ready.to.cluster <- NULL perform.quantile.coding <- 0 if (perform.quantile.coding==1) { for (t in 1:length(ttt)) { print(t) temp0 <- eval(parse(text=ttt[t])) temp0 <- as.matrix(temp0) temp0 <- round(temp0*100,0) temp1 <- ifelse(temp0==0,NA,temp0) temp2 <- as.numeric(unlist(temp1)) temp3 <- temp2[!is.na(temp2)] temp4 <- density(temp3) temp5 <- round(mean(temp3,trim=0.95),0) temp6 <- max(temp3) temp7 <- c(0:temp6) temp8 <- dpois(temp7, temp5) temp9 <- ppois((temp1-1), temp5, lower.tail = FALSE) temp10 <- ifelse(is.na(temp9),1,temp9) temp11 <- ifelse(temp100 temp13 <- temp11[temp12,] temptemp <- seq(from=1,to=dim(temp13)[1],by=size.2.use[t]) temp13 <- temp13[temptemp,] temp14 <- t(temp13) temp15 <- dimnames(temp14)[[2]] temp16 <- ttt[t] temp17 <- str_replace_all(temp16,"Final_Analysis_Ready_Counts_","") for (i in 1:length(temp15)) { temp15[i] <- paste(c("Sample_",temp17,"_Pos_",temp15[i]),collapse="",sep="") } dimnames(temp14)[[2]] <- temp15 temp14 <- temp14[ensure.order,] temp18 <- as.numeric(temp14) temp18 <- temp18[temp18>0] temp19 <- as.numeric(quantile(temp18,0.25)) temp20 <- as.numeric(quantile(temp18,0.5)) temp21 <- as.numeric(quantile(temp18,0.75)) temp22 <- ifelse(temp14>temp21,100,0) temp23a <- ifelse(temp14<=temp21,1,0) temp23b <- ifelse(temp14>temp20,1,0) temp23 <- temp23a+temp23b temp23 <- ifelse(temp23==2,75,0) temp24a <- ifelse(temp14<=temp20,1,0) temp24b <- ifelse(temp14>temp19,1,0) temp24 <- temp24a+temp24b temp24 <- ifelse(temp24==2,50,0) temp25a <- ifelse(temp14<=temp19,1,0) temp25b <- ifelse(temp14>0,1,0) temp25 <- temp25a+temp25b temp25 <- ifelse(temp25==2,25,0) temp26 <- temp22+temp23+temp24+temp25 ready.to.cluster <- cbind(ready.to.cluster,temp26) print(dim(ready.to.cluster)) } } else { for (t in 1:length(ttt)) { print(t) temp0 <- eval(parse(text=ttt[t])) temp0 <- as.matrix(temp0) temp0 <- round(temp0*100,0) temp1 <- ifelse(temp0==0,NA,temp0) temp2 <- as.numeric(unlist(temp1)) temp3 <- temp2[!is.na(temp2)] temp4 <- density(temp3) temp5 <- round(mean(temp3,trim=0.95),0) temp6 <- max(temp3) temp7 <- c(0:temp6) temp8 <- dpois(temp7, temp5) temp9 <- ppois((temp1-1), temp5, lower.tail = FALSE) temp10 <- ifelse(is.na(temp9),1,temp9) temp11 <- ifelse(temp100 temp13 <- temp11[temp12,] temptemp <- seq(from=1,to=dim(temp13)[1],by=size.2.use[t]) temp13 <- temp13[temptemp,] temp14 <- t(temp13) temp15 <- dimnames(temp14)[[2]] temp16 <- ttt[t] temp17 <- str_replace_all(temp16,"Final_Analysis_Ready_Counts_","") for (i in 1:length(temp15)) { temp15[i] <- paste(c("Sample_",temp17,"_Pos_",temp15[i]),collapse="",sep="") } dimnames(temp14)[[2]] <- temp15 temp14 <- temp14[ensure.order,] ready.to.cluster <- cbind(ready.to.cluster,temp14) print(dim(ready.to.cluster)) } } setwd("/data/johnsonko/SideProject/Helen/20200811/BinaryCodeAndCrunch") write.table(ready.to.cluster,"ready.to.cluster.txt",sep="\t") coded.ready.to.cluster <- ifelse(ready.to.cluster>0,1,0) write.table(coded.ready.to.cluster,"coded.ready.to.cluster.txt",sep="\t") working <- apply(coded.ready.to.cluster,2,paste,collapse="_",sep="_") temp <- names(working) temptemp <- strsplit(temp,"_Pos_") temptemp <- as.data.frame(temptemp) temptemp <- t(temptemp) dimnames(temptemp)[[1]] <- temp temp <- as.character(temptemp[,2]) temp <- strsplit(temp,"X") temp <- as.data.frame(temp) temp <- t(temp) temptemp <- cbind(temptemp,temp) temptemp <- cbind(temptemp,as.character(working)) ready.to.crunch <- temptemp dimnames(ready.to.crunch)[[2]] <- c("Sample","Location","Xpos","Ypos","String") write.table(ready.to.crunch,"ready.to.crunch.txt",sep="\t") unique.samples <- unique(sort(unlist(ready.to.crunch[,1]))) unique.strings <- unique(sort(unlist(ready.to.crunch[,5]))) final.crunch <- NULL for (i in 1:length(unique.samples)) { print(i) temp1 <- ready.to.crunch[ready.to.crunch[,1]==unique.samples[i],] temp2 <- table(temp1[,5]) temp3 <- setdiff(unique.strings,names(temp2)) temp4 <- rep(0,length(temp3)) names(temp4) <- temp3 temp5 <- c(temp2,temp4) temp5 <- temp5[unique.strings] final.crunch <- cbind(final.crunch,temp5) } dimnames(final.crunch)[[2]] <- unique.samples dimnames(final.crunch)[[1]] <- unique.strings write.table(final.crunch,"final.crunch.txt",sep="\t") ############################################################# # Test Bin Counts ############################################################# library(gplots) library(ggplot2) tiff("Clustered_HeatMap_PreTesting.tiff",width = 8, height = 8, units = "in", res=300) cc <- greenred(64) hhh <- heatmap.2(final.crunch,trace="none",density.info="none",col=cc,labRow=dimnames(final.crunch)[[1]],labCol=dimnames(final.crunch)[[2]],scale="none",mar=c(10,10)) dev.off() tiff("PCA_PreTesting.tiff",width = 8, height = 8, units = "in", res=300) col.2.use <- c(rep("red",5),rep("green",4),rep("blue",5)) pca.results <- prcomp(t(final.crunch)) totalvar <- (pca.results[[1]]^2) variancePer <- round(totalvar/sum(totalvar)*100,1) variancePer <- variancePer[1:3] pca.x <- pca.results$x[,c(1:3)] palette("default") x.range <- range(pca.x[,1]) y.range <- range(pca.x[,2]) xlab <- paste(c("Principal Component 1 (",variancePer[1],"%)"),collapse="") ylab <- paste(c("Principal Component 2 (",variancePer[2],"%)"),collapse="") plot(pca.x[,1],pca.x[,2],xlab=xlab,ylab=ylab,type='n') points(pca.x[,1],pca.x[,2],lwd=0.5,col=col.2.use,cex=2,pch=19) points(pca.x[,1],pca.x[,2],lwd=0.5,col=1,cex=2,pch=21) legend("topright", title="Legend",c("AZ","Control","PD"), col=c("red","green","blue"), horiz=TRUE, cex=0.8, pch = 19) dev.off() #------------------------------------------------------------------------------- # ANOVA #------------------------------------------------------------------------------- library(car) Final.working.data <- final.crunch ggg <- c(rep("AZ",5),rep("Control",4),rep("PD",5)) running.pvs <- NULL for (i in 1:dim(Final.working.data)[1]) { print(i) probe.data <- as.numeric(unlist(Final.working.data[i,])) temp <- data.frame(DATA=probe.data,GROUP=factor(ggg)) aov.results <- aov(DATA~GROUP,data=temp) if (deviance(aov.results ) > sqrt(.Machine$double.eps)) { temp <- Anova(aov.results,type="III",singular.ok=TRUE) temp <- summary(aov.results) temp <- as.numeric(unlist(temp))[9] running.pvs <- c(running.pvs,temp) } else { running.pvs <- c(running.pvs,1) } } names(running.pvs) <- dimnames(Final.working.data)[[1]] #------------------------------------------------------------------------------- # FDR MCC (alpha=0.05) #------------------------------------------------------------------------------- library("multtest") temp1 <- mt.rawp2adjp(running.pvs, proc="BH") temp2 <- temp1$adj[order(temp1$index),] temp2 <- as.data.frame(temp2) dimnames(temp2)[[1]] <- names(running.pvs) write.table(temp2,"ANOVA_Results.txt",sep="\t",row.names=T) #------------------------------------------------------------------------------- # Non-Parametric ANOVA #------------------------------------------------------------------------------- Final.working.data <- final.crunch ggg <- c(rep("AZ",5),rep("Control",4),rep("PD",5)) running.pvs <- NULL for (i in 1:dim(Final.working.data)[1]) { print(i) probe.data <- as.numeric(unlist(Final.working.data[i,])) temp <- data.frame(DATA=probe.data,GROUP=factor(ggg)) temptemp <- kruskal.test(DATA ~ GROUP, data = temp) temp <- temptemp$p.value running.pvs <- c(running.pvs,temp) } names(running.pvs) <- dimnames(Final.working.data)[[1]] #------------------------------------------------------------------------------- # FDR MCC (alpha=0.05) #------------------------------------------------------------------------------- library("multtest") temp1 <- mt.rawp2adjp(running.pvs, proc="BH") temp2 <- temp1$adj[order(temp1$index),] temp2 <- as.data.frame(temp2) dimnames(temp2)[[1]] <- names(running.pvs) write.table(temp2,"NonParametric_ANOVA_Results.txt",sep="\t",row.names=T) #------------------------------------------------------------------------------- # Parametric Pos-Hoc Testing #------------------------------------------------------------------------------- posthoc.data <- Final.working.data running.posthoc <- NULL running.diffs <- NULL for (i in 1:dim(posthoc.data)[1]) { print(i) print(dim(posthoc.data)[1]) temp1 <- as.numeric(posthoc.data[i,]) temp2 <- data.frame(DATA=temp1,Class=ggg) temp3 <- aov(DATA~Class,data=temp2) temp4 <- TukeyHSD(temp3) temp5 <- temp4[[1]] temp6 <- temp5[,4] running.posthoc <- rbind(running.posthoc,temp6) temp7 <- temp5[,1] running.diffs <- rbind(running.diffs,temp7) } running.posthoc <- as.data.frame(running.posthoc) dimnames(running.posthoc)[[1]] <- dimnames(posthoc.data)[[1]] write.table(running.posthoc,"Parametric_PostHoc_Results.txt",sep="\t",row.names=T) #------------------------------------------------------------------------------- # Non-Parametric Pos-Hoc Testing #------------------------------------------------------------------------------- library(FSA) posthoc.data <- Final.working.data running.posthoc <- NULL for (i in 1:dim(posthoc.data)[1]) { print(i) print(dim(posthoc.data)[1]) temp1 <- as.numeric(posthoc.data[i,]) temp2 <- data.frame(DATA=temp1,GROUP=ggg) temp3 <- dunnTest(DATA~GROUP,data=temp2) temp4 <- temp3[2][[1]][,3] running.posthoc <- rbind(running.posthoc,temp4) } running.posthoc <- as.data.frame(running.posthoc) dimnames(running.posthoc)[[1]] <- dimnames(posthoc.data)[[1]] temp <- as.character(unlist(temp3[2][[1]][,1])) temp <- str_replace_all(temp," ","") temp <- str_replace_all(temp,"-","_vs_") dimnames(running.posthoc)[[2]] <- temp write.table(running.posthoc,"Non_Paramatric_PostHoc_Results.txt",sep="\t",row.names=T) #------------------------------------------------------------------------------- # Mean calculation #------------------------------------------------------------------------------- dd <- Final.working.data temp0 <- dd[,c(1:5)] AZ.mean <- apply(temp0,1,mean) AZ.sd <- apply(temp0,1,sd) temp0 <- dd[,c(6:9)] Control.mean <- apply(temp0,1,mean) Control.sd <- apply(temp0,1,sd) temp0 <- dd[,c(10:14)] PD.mean <- apply(temp0,1,mean) PD.sd <- apply(temp0,1,sd) cx.out <- cbind(Control.mean,Control.sd,AZ.mean,AZ.sd,PD.mean,PD.sd) write.table(cx.out,"Mean_SD_Results.txt",sep="\t",row.names=T) #------------------------------------------------------------------------------- # Post Testing Plots #------------------------------------------------------------------------------- hits <- read.table("hits.txt",header=F) hits <- as.character(hits[,1]) fff <- Final.working.data[hits,] tiff("Clustered_HeatMap_PostTesting.tiff",width = 8, height = 8, units = "in", res=300) cc <- greenred(64) hhh <- heatmap.2(fff,trace="none",density.info="none",col=cc,labRow=dimnames(fff)[[1]],labCol=dimnames(fff)[[2]],mar=c(10,15)) dev.off() tiff("PCA_PostTesting.tiff",width = 8, height = 8, units = "in", res=300) col.2.use <- c(rep("red",5),rep("green",4),rep("blue",5)) pca.results <- prcomp(t(fff)) totalvar <- (pca.results[[1]]^2) variancePer <- round(totalvar/sum(totalvar)*100,1) variancePer <- variancePer[1:3] pca.x <- pca.results$x[,c(1:3)] palette("default") x.range <- range(pca.x[,1]) y.range <- range(pca.x[,2]) xlab <- paste(c("Principal Component 1 (",variancePer[1],"%)"),collapse="") ylab <- paste(c("Principal Component 2 (",variancePer[2],"%)"),collapse="") plot(pca.x[,1],pca.x[,2],xlab=xlab,ylab=ylab,type='n') points(pca.x[,1],pca.x[,2],lwd=0.5,col=col.2.use,cex=2,pch=19) points(pca.x[,1],pca.x[,2],lwd=0.5,col=1,cex=2,pch=21) legend("top", title="Legend",c("AZ","Control","PD"), col=c("red","green","blue"), horiz=TRUE, cex=0.8, pch = 19) dev.off() #------------------------------------------------------------------------------- # Plotting out patterns #------------------------------------------------------------------------------- setwd("/data/johnsonko/SideProject/Helen/20200811/BinaryCodeAndCrunch") load("20200924.RData") #final.crunch <- read.table("final.crunch.txt") #ready.to.cluster <- read.table("ready.to.cluster.txt") coded.ready.to.cluster <- read.table("coded.ready.to.cluster.txt") working <- apply(coded.ready.to.cluster,2,paste,collapse="_",sep="_") setwd("/data/johnsonko/SideProject/Helen/20200811/Bulb_Locations") final.Bulb.Locations.AZ109 <- read.table("Bulb_Locations_AZ109.txt") # AZ_109_146 final.Bulb.Locations.AZ84 <- read.table("Bulb_Locations_AZ84.txt") # AZ_84_145 final.Bulb.Locations.AZ90 <- read.table("Bulb_Locations_AZ90.txt") # AZ_90_242 final.Bulb.Locations.AZ99 <- read.table("Bulb_Locations_AZ99.txt") # AZ_99_140 final.Bulb.Locations.H190 <- read.table("Bulb_Locations_H190.txt") # Control_H190_260 final.Bulb.Locations.H250 <- read.table("Bulb_Locations_H250.txt") # Control_H250_185 final.Bulb.Locations.H251 <- read.table("Bulb_Locations_H251.txt") # AZ_251_146 final.Bulb.Locations.OFB57 <- read.table("Bulb_Locations_OFB57.txt") # Control_OFB57_194 final.Bulb.Locations.OFB6a <- read.table("Bulb_Locations_OFB6a.txt") # Control_OFB6A_107 final.Bulb.Locations.PD52 <- read.table("Bulb_Locations_PD52.txt") # PD_52_247 final.Bulb.Locations.PD56 <- read.table("Bulb_Locations_PD56.txt") # PD_56_236 final.Bulb.Locations.PD58 <- read.table("Bulb_Locations_PD58.txt") # PD_58_22 final.Bulb.Locations.PD77 <- read.table("Bulb_Locations_PD77.txt") # PD_77_197 final.Bulb.Locations.PD79 <- read.table("Bulb_Locations_PD79.txt") # PD_79_201 setwd("/data/johnsonko/SideProject/Helen/20200811/Analysis_Ready") Final_Analysis_Ready_Counts_AZ_109_146 <- read.table("Final_Analysis_Ready_Counts_AZ_109_146.txt",header=T) Final_Analysis_Ready_Counts_AZ_251_146 <- read.table("Final_Analysis_Ready_Counts_AZ_251_146.txt",header=T) Final_Analysis_Ready_Counts_AZ_84_145 <- read.table("Final_Analysis_Ready_Counts_AZ_84_145.txt",header=T) Final_Analysis_Ready_Counts_AZ_90_242 <- read.table("Final_Analysis_Ready_Counts_AZ_90_242.txt",header=T) Final_Analysis_Ready_Counts_AZ_99_140 <- read.table("Final_Analysis_Ready_Counts_AZ_99_140.txt",header=T) Final_Analysis_Ready_Counts_Control_H190_260 <- read.table("Final_Analysis_Ready_Counts_Control_H190_260.txt",header=T) Final_Analysis_Ready_Counts_Control_H250_185 <- read.table("Final_Analysis_Ready_Counts_Control_H250_185.txt",header=T) Final_Analysis_Ready_Counts_Control_OFB57_194 <- read.table("Final_Analysis_Ready_Counts_Control_OFB57_194.txt",header=T) Final_Analysis_Ready_Counts_Control_OFB6A_107 <- read.table("Final_Analysis_Ready_Counts_Control_OFB6A_107.txt",header=T) Final_Analysis_Ready_Counts_PD_52_247 <- read.table("Final_Analysis_Ready_Counts_PD_52_247.txt",header=T) Final_Analysis_Ready_Counts_PD_56_236 <- read.table("Final_Analysis_Ready_Counts_PD_56_236.txt",header=T) Final_Analysis_Ready_Counts_PD_58_229 <- read.table("Final_Analysis_Ready_Counts_PD_58_229.txt",header=T) Final_Analysis_Ready_Counts_PD_77_197 <- read.table("Final_Analysis_Ready_Counts_PD_77_197.txt",header=T) Final_Analysis_Ready_Counts_PD_79_201 <- read.table("Final_Analysis_Ready_Counts_PD_79_201.txt",header=T) ttt <- dimnames(final.Bulb.Locations.AZ109)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.AZ109 <- ttt ttt <- dimnames(final.Bulb.Locations.AZ84)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.AZ84 <- ttt ttt <- dimnames(final.Bulb.Locations.AZ90)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.AZ90 <- ttt ttt <- dimnames(final.Bulb.Locations.AZ99)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.AZ99 <- ttt ttt <- dimnames(final.Bulb.Locations.H190)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.ControlH190 <- ttt ttt <- dimnames(final.Bulb.Locations.H250)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.ControlH250 <- ttt ttt <- dimnames(final.Bulb.Locations.H251)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.AZH251 <- ttt ttt <- dimnames(final.Bulb.Locations.OFB57)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.ControlOFB57 <- ttt ttt <- dimnames(final.Bulb.Locations.OFB6a)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.ControlOFB6a <- ttt ttt <- dimnames(final.Bulb.Locations.PD52)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.PD52 <- ttt ttt <- dimnames(final.Bulb.Locations.PD56)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.PD56 <- ttt ttt <- dimnames(final.Bulb.Locations.PD58)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.PD58 <- ttt ttt <- dimnames(final.Bulb.Locations.PD77)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.PD77 <- ttt ttt <- dimnames(final.Bulb.Locations.PD79)[[1]] ttt <- strsplit(ttt,"@") ttt <- as.data.frame(ttt) ttt <- t(ttt) ttt <- ttt[,2] ttt <- as.character(ttt) ttt <- strsplit(ttt,"X") ttt <- as.data.frame(ttt) ttt <- t(ttt) dimnames(ttt)[[1]] <- NULL plot.bulb.locations.PD79 <- ttt write.table(plot.bulb.locations.AZ109,"plot.bulb.locations.AZ109.txt",sep="\t") write.table(plot.bulb.locations.AZ84,"plot.bulb.locations.AZ84.txt",sep="\t") write.table(plot.bulb.locations.AZ90,"plot.bulb.locations.AZ90.txt",sep="\t") write.table(plot.bulb.locations.AZ99,"plot.bulb.locations.AZ99.txt",sep="\t") write.table(plot.bulb.locations.AZH251,"plot.bulb.locations.AZH251.txt",sep="\t") write.table(plot.bulb.locations.ControlH190,"plot.bulb.locations.ControlH190.txt",sep="\t") write.table(plot.bulb.locations.ControlH250,"plot.bulb.locations.ControlH250.txt",sep="\t") write.table(plot.bulb.locations.ControlOFB57,"plot.bulb.locations.ControlOFB57.txt",sep="\t") write.table(plot.bulb.locations.ControlOFB6a,"plot.bulb.locations.ControlOFB6a.txt",sep="\t") write.table(plot.bulb.locations.PD52,"plot.bulb.locations.PD52.txt",sep="\t") write.table(plot.bulb.locations.PD56,"plot.bulb.locations.PD56.txt",sep="\t") write.table(plot.bulb.locations.PD58,"plot.bulb.locations.PD58.txt",sep="\t") write.table(plot.bulb.locations.PD77,"plot.bulb.locations.PD77.txt",sep="\t") write.table(plot.bulb.locations.PD79,"plot.bulb.locations.PD79.txt",sep="\t") plot.bulb.locations.AZ109 <- read.table("plot.bulb.locations.AZ109.txt") plot.bulb.locations.AZ84 <- read.table("plot.bulb.locations.AZ84.txt") plot.bulb.locations.AZ90 <- read.table("plot.bulb.locations.AZ90.txt") plot.bulb.locations.AZ99 <- read.table("plot.bulb.locations.AZ99.txt") plot.bulb.locations.AZH251 <- read.table("plot.bulb.locations.AZH251.txt") plot.bulb.locations.ControlH190 <- read.table("plot.bulb.locations.ControlH190.txt") plot.bulb.locations.ControlH250 <- read.table("plot.bulb.locations.ControlH250.txt") plot.bulb.locations.ControlOFB57 <- read.table("plot.bulb.locations.ControlOFB57.txt") plot.bulb.locations.ControlOFB6a <- read.table("plot.bulb.locations.ControlOFB6a.txt") plot.bulb.locations.PD52 <- read.table("plot.bulb.locations.PD52.txt") plot.bulb.locations.PD56 <- read.table("plot.bulb.locations.PD56.txt") plot.bulb.locations.PD58 <- read.table("plot.bulb.locations.PD58.txt") plot.bulb.locations.PD77 <- read.table("plot.bulb.locations.PD77.txt") plot.bulb.locations.PD79 <- read.table("plot.bulb.locations.PD79.txt") omp.hits <- c("0_0_0_0_0_0_1_0_0_0_0_0_0_0_0_0_1_0_0_0_0_0_0_0_1", "0_0_1_0_0_0_1_0_0_0_0_0_0_0_0_0_1_0_0_0_0_0_0_0_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_AMYLOID", "CALBINDIN", "CD31", "CH_NEUN", "CNPASE", "COLLAGEN_IV", "DAPI", "GFAP", "HISTONES", "HLADR", "IBA1", "MAP2", "MBP", "NEURO_HEAVY", "NEURO_LIGHT", "OMP", "PGP9_5", "RB_CALRETININ", "S100", "SYNAPTOPHYSIN", "TAU", "TOMATO_LECTIN", "TYR_HYDROXYLASE", "UEA_LECTIN") temp3 <- matrix(as.numeric(unlist(temp2)),dim(temp2)[1],dim(temp2)[2]) temp3 <- ifelse(temp3==1,0,1) dimnames(temp3) <- dimnames(temp2) col.2.use <- rainbow(length(omp.hits)) hhh <- heatmap.2(as.matrix(temp3),density.info="none",labRow=dimnames(temp3)[[1]],labCol="",scale="none",Rowv=TRUE,Colv=TRUE,col=c(0,1),ColSideColors=col.2.use,key=FALSE,trace="both",linecol=NULL,tracecol="gray",margins = c(5, 10)) temp <- hhh[2][[1]] names(temp) <- col.2.use temp <- sort(temp) col.2.use <- names(temp) temp <- hhh[2][[1]] names(temp) <- c(1:60) temp <- sort(temp) combo <- names(temp) hhh <- heatmap.2(as.matrix(temp3),density.info="none",labCol=combo,labRow=dimnames(temp3)[[1]],scale="none",Rowv=TRUE,Colv=TRUE,col=c(0,1),ColSideColors=col.2.use,key=FALSE,trace="both",linecol=NULL,tracecol="gray",margins = c(5, 10),xlab="Label Combinations (OMP+, Kruskal-Wallis P < 0.05)",adjCol = c(NA,0.4)) #tiff("Omp_String_HeatMap_20200930.tiff",res=300,width = 6, height = 3, units = "in") svg("Omp_String_HeatMap_20200930.svg",width = 12, height = 5) hhh <- heatmap.2(as.matrix(temp3),density.info="none",labCol=combo,labRow=dimnames(temp3)[[1]],scale="none",Rowv=TRUE,Colv=TRUE,col=c(0,1),ColSideColors=col.2.use,key=FALSE,trace="both",linecol=NULL,tracecol="gray",margins = c(5, 10),xlab="Label Combinations (OMP+, Kruskal-Wallis P < 0.05)",adjCol = c(NA,0.4)) dev.off() omp.hits <- dimnames(temp3)[[2]][hhh[[2]]] col.2.use <- rainbow(length(omp.hits)) for (t in 1:length(omp.hits)) { print(t) print(length(omp.hits)) temp <- omp.hits[t] temp <- working[working==temp] temp <- names(temp) temptemp <- strsplit(temp,"_Pos_") temptemp <- as.data.frame(temptemp) temptemp <- t(temptemp) dimnames(temptemp)[[1]] <- temp temp <- as.character(temptemp[,2]) temp <- strsplit(temp,"X") temp <- as.data.frame(temp) temp <- t(temp) temptemp <- cbind(temptemp,temp) dimnames(temptemp)[[2]] <- c("Sample","Location","Xpos","Ypos") #pdf(paste(c("OMP_",omp.hits[t],".pdf"),collapse="",sep=""),width = 28950/1000, height = 6030/1000) pdf(paste(c("OMP_String_Combination_",t,".pdf"),collapse="",sep=""),width = 28950/1000, height = 6030/1000) # AZ_109_146 new.x <- as.numeric(unlist(plot.bulb.locations.AZ109[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ109[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_109_146") if(length(grep("AZ_109_146",temptemp[,1]))>0) { if(length(grep("AZ_109_146",temptemp[,1]))==1) { temp <- temptemp[grep("AZ_109_146",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("AZ_109_146",temptemp[,1]))>1) { temp <- temptemp[grep("AZ_109_146",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # AZ_84_145 new.x <- as.numeric(unlist(plot.bulb.locations.AZ84[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ84[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_84_145") if(length(grep("AZ_84_145",temptemp[,1]))>0) { if(length(grep("AZ_84_145",temptemp[,1]))==1) { temp <- temptemp[grep("AZ_84_145",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("AZ_84_145",temptemp[,1]))>1) { temp <- temptemp[grep("AZ_84_145",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # AZ_90_242 new.x <- as.numeric(unlist(plot.bulb.locations.AZ90[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ90[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_90_242") if(length(grep("AZ_90_242",temptemp[,1]))>0) { if(length(grep("AZ_90_242",temptemp[,1]))==1) { temp <- temptemp[grep("AZ_90_242",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("AZ_90_242",temptemp[,1]))>1) { temp <- temptemp[grep("AZ_90_242",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # AZ_99_140 new.x <- as.numeric(unlist(plot.bulb.locations.AZ99[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ99[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_99_140") if(length(grep("AZ_99_140",temptemp[,1]))>0) { if(length(grep("AZ_99_140",temptemp[,1]))==1) { temp <- temptemp[grep("AZ_99_140",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("AZ_99_140",temptemp[,1]))>1) { temp <- temptemp[grep("AZ_99_140",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # AZ_251_146 new.x <- as.numeric(unlist(plot.bulb.locations.AZH251[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZH251[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_251_146") if(length(grep("AZ_251_146",temptemp[,1]))>0) { if(length(grep("AZ_251_146",temptemp[,1]))==1) { temp <- temptemp[grep("AZ_251_146",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("AZ_251_146",temptemp[,1]))>1) { temp <- temptemp[grep("AZ_251_146",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # Control_H190_260 new.x <- as.numeric(unlist(plot.bulb.locations.ControlH190[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlH190[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_H190_260") if(length(grep("Control_H190_260",temptemp[,1]))>0) { if(length(grep("Control_H190_260",temptemp[,1]))==1) { temp <- temptemp[grep("Control_H190_260",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("Control_H190_260",temptemp[,1]))>1) { temp <- temptemp[grep("Control_H190_260",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # Control_H250_185 new.x <- as.numeric(unlist(plot.bulb.locations.ControlH250[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlH250[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_H250_185") if(length(grep("Control_H250_185",temptemp[,1]))>0) { if(length(grep("Control_H250_185",temptemp[,1]))==1) { temp <- temptemp[grep("Control_H250_185",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("Control_H250_185",temptemp[,1]))>1) { temp <- temptemp[grep("Control_H250_185",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # Control_OFB57_194 new.x <- as.numeric(unlist(plot.bulb.locations.ControlOFB57[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlOFB57[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_OFB57_194") if(length(grep("Control_OFB57_194",temptemp[,1]))>0) { if(length(grep("Control_OFB57_194",temptemp[,1]))==1) { temp <- temptemp[grep("Control_OFB57_194",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("Control_OFB57_194",temptemp[,1]))>1) { temp <- temptemp[grep("Control_OFB57_194",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # Control_OFB6A_107 new.x <- as.numeric(unlist(plot.bulb.locations.ControlOFB6a[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlOFB6a[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_OFB6A_107") if(length(grep("Control_OFB6A_107",temptemp[,1]))>0) { if(length(grep("Control_OFB6A_107",temptemp[,1]))==1) { temp <- temptemp[grep("Control_OFB6A_107",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("Control_OFB6A_107",temptemp[,1]))>1) { temp <- temptemp[grep("Control_OFB6A_107",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # PD_52_247 new.x <- as.numeric(unlist(plot.bulb.locations.PD52[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD52[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_52_247") if(length(grep("PD_52_247",temptemp[,1]))>0) { if(length(grep("PD_52_247",temptemp[,1]))==1) { temp <- temptemp[grep("PD_52_247",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("PD_52_247",temptemp[,1]))>1) { temp <- temptemp[grep("PD_52_247",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # PD_56_236 new.x <- as.numeric(unlist(plot.bulb.locations.PD56[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD56[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_56_236") if(length(grep("PD_56_236",temptemp[,1]))>0) { if(length(grep("PD_56_236",temptemp[,1]))==1) { temp <- temptemp[grep("PD_56_236",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("PD_56_236",temptemp[,1]))>1) { temp <- temptemp[grep("PD_56_236",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # PD_58_22 new.x <- as.numeric(unlist(plot.bulb.locations.PD58[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD58[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_58_22") if(length(grep("PD_58_22",temptemp[,1]))>0) { if(length(grep("PD_58_22",temptemp[,1]))==1) { temp <- temptemp[grep("PD_58_22",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("PD_58_22",temptemp[,1]))>1) { temp <- temptemp[grep("PD_58_22",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # PD_77_197 new.x <- as.numeric(unlist(plot.bulb.locations.PD77[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD77[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_77_197") if(length(grep("PD_77_197",temptemp[,1]))>0) { if(length(grep("PD_77_197",temptemp[,1]))==1) { temp <- temptemp[grep("PD_77_197",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("PD_77_197",temptemp[,1]))>1) { temp <- temptemp[grep("PD_77_197",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # PD_79_201 new.x <- as.numeric(unlist(plot.bulb.locations.PD79[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD79[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_79_201") if(length(grep("PD_79_201",temptemp[,1]))>0) { if(length(grep("PD_79_201",temptemp[,1]))==1) { temp <- temptemp[grep("PD_79_201",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("PD_79_201",temptemp[,1]))>1) { temp <- temptemp[grep("PD_79_201",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } dev.off() } omp.catch.all <- NULL for (t in 1:length(omp.hits)) { print(t) print(length(omp.hits)) temp <- omp.hits[t] temp <- working[working==temp] temp <- names(temp) temptemp <- strsplit(temp,"_Pos_") temptemp <- as.data.frame(temptemp) temptemp <- t(temptemp) dimnames(temptemp)[[1]] <- temp temp <- as.character(temptemp[,2]) temp <- strsplit(temp,"X") temp <- as.data.frame(temp) temp <- t(temp) temptemp <- cbind(temptemp,temp) temptemp <- cbind(temptemp,col.2.use[t]) dimnames(temptemp)[[2]] <- c("Sample","Location","Xpos","Ypos","Color") omp.catch.all <- rbind(omp.catch.all,temptemp) } pdf("OMP_All_String_Hits.pdf",width = 28950/1000, height = 6030/1000) # AZ_109_146 new.x <- as.numeric(unlist(plot.bulb.locations.AZ109[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ109[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_109_146") if(length(grep("AZ_109_146",omp.catch.all[,1]))>0) { if(length(grep("AZ_109_146",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("AZ_109_146",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("AZ_109_146",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("AZ_109_146",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # AZ_84_145 new.x <- as.numeric(unlist(plot.bulb.locations.AZ84[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ84[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_84_145") if(length(grep("AZ_84_145",omp.catch.all[,1]))>0) { if(length(grep("AZ_84_145",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("AZ_84_145",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("AZ_84_145",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("AZ_84_145",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # AZ_90_242 new.x <- as.numeric(unlist(plot.bulb.locations.AZ90[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ90[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_90_242") if(length(grep("AZ_90_242",omp.catch.all[,1]))>0) { if(length(grep("AZ_90_242",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("AZ_90_242",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("AZ_90_242",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("AZ_90_242",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # AZ_99_140 new.x <- as.numeric(unlist(plot.bulb.locations.AZ99[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ99[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_99_140") if(length(grep("AZ_99_140",omp.catch.all[,1]))>0) { if(length(grep("AZ_99_140",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("AZ_99_140",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("AZ_99_140",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("AZ_99_140",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # AZ_251_146 new.x <- as.numeric(unlist(plot.bulb.locations.AZH251[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZH251[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_251_146") if(length(grep("AZ_251_146",omp.catch.all[,1]))>0) { if(length(grep("AZ_251_146",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("AZ_251_146",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("AZ_251_146",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("AZ_251_146",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # Control_H190_260 new.x <- as.numeric(unlist(plot.bulb.locations.ControlH190[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlH190[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_H190_260") if(length(grep("Control_H190_260",omp.catch.all[,1]))>0) { if(length(grep("Control_H190_260",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("Control_H190_260",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("Control_H190_260",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("Control_H190_260",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # Control_H250_185 new.x <- as.numeric(unlist(plot.bulb.locations.ControlH250[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlH250[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_H250_185") if(length(grep("Control_H250_185",omp.catch.all[,1]))>0) { if(length(grep("Control_H250_185",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("Control_H250_185",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("Control_H250_185",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("Control_H250_185",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # Control_OFB57_194 new.x <- as.numeric(unlist(plot.bulb.locations.ControlOFB57[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlOFB57[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_OFB57_194") if(length(grep("Control_OFB57_194",omp.catch.all[,1]))>0) { if(length(grep("Control_OFB57_194",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("Control_OFB57_194",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("Control_OFB57_194",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("Control_OFB57_194",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # Control_OFB6A_107 new.x <- as.numeric(unlist(plot.bulb.locations.ControlOFB6a[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlOFB6a[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_OFB6A_107") if(length(grep("Control_OFB6A_107",omp.catch.all[,1]))>0) { if(length(grep("Control_OFB6A_107",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("Control_OFB6A_107",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("Control_OFB6A_107",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("Control_OFB6A_107",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # PD_52_247 new.x <- as.numeric(unlist(plot.bulb.locations.PD52[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD52[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_52_247") if(length(grep("PD_52_247",omp.catch.all[,1]))>0) { if(length(grep("PD_52_247",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("PD_52_247",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("PD_52_247",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("PD_52_247",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # PD_56_236 new.x <- as.numeric(unlist(plot.bulb.locations.PD56[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD56[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_56_236") if(length(grep("PD_56_236",omp.catch.all[,1]))>0) { if(length(grep("PD_56_236",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("PD_56_236",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("PD_56_236",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("PD_56_236",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # PD_58_22 new.x <- as.numeric(unlist(plot.bulb.locations.PD58[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD58[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_58_22") if(length(grep("PD_58_22",omp.catch.all[,1]))>0) { if(length(grep("PD_58_22",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("PD_58_22",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("PD_58_22",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("PD_58_22",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # PD_77_197 new.x <- as.numeric(unlist(plot.bulb.locations.PD77[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD77[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_77_197") if(length(grep("PD_77_197",omp.catch.all[,1]))>0) { if(length(grep("PD_77_197",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("PD_77_197",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("PD_77_197",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("PD_77_197",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # PD_79_201 new.x <- as.numeric(unlist(plot.bulb.locations.PD79[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD79[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_79_201") if(length(grep("PD_79_201",omp.catch.all[,1]))>0) { if(length(grep("PD_79_201",omp.catch.all[,1]))==1) { temp <- omp.catch.all[grep("PD_79_201",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("PD_79_201",omp.catch.all[,1]))>1) { temp <- omp.catch.all[grep("PD_79_201",omp.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } dev.off() tau.hits <- c("0_0_0_0_0_0_0_0_1_0_0_0_1_0_0_0_0_1_0_0_1_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_0_0_1_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_1_0_0_0_1_0_0_1_0_1_0_0_1_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_0_0_1_0_0_1_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_1_0_0_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_1_0_1_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_1_0_1_0_0_1_1_0_0_0", "0_0_0_0_0_0_0_0_1_0_0_0_1_0_0_1_0_1_0_0_0_1_0_0_0", "0_0_0_0_1_0_0_0_0_0_0_0_1_0_0_1_0_1_0_0_0_1_0_0_0", "0_0_1_0_1_0_0_0_0_0_0_0_1_0_0_1_0_1_0_0_1_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_0_0_0_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_1_0_0_0_1_0_0_0_0_1_0_0_0_1_0_0_0", "0_0_1_0_0_0_0_0_0_0_0_0_1_0_0_1_0_1_0_0_1_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_1_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_1_0_1_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_1_0_1_0_0_1_1_0_0_0", "0_0_0_0_0_0_0_0_0_1_0_0_1_0_0_1_0_1_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_1_0_0_0_0_0_0_0_0_1_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_1_0_0_0_0_0_0_0_0_1_0_0_1_1_0_0_0", "0_0_0_0_0_0_0_0_1_0_0_0_0_0_0_1_0_1_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_1_0_0_0_0_0_0_1_0_1_0_0_1_1_0_0_0", "0_0_0_0_0_0_0_0_1_0_0_0_1_0_0_0_0_0_0_0_0_1_0_0_0", "0_0_1_0_0_0_0_0_0_0_0_0_1_0_0_1_0_1_0_0_0_1_0_0_0", "0_0_1_0_1_0_0_0_0_0_0_0_1_0_0_1_0_1_0_0_0_1_0_0_0") tau.hits <- sort(tau.hits) temp1 <- strsplit(tau.hits,"_") temp2 <- as.data.frame(temp1) dimnames(temp2)[[2]] <- tau.hits dimnames(temp2)[[1]] <- c("ALPHA_SYNUCLEIN", "BETA_AMYLOID", "CALBINDIN", "CD31", "CH_NEUN", "CNPASE", "COLLAGEN_IV", "DAPI", "GFAP", "HISTONES", "HLADR", "IBA1", "MAP2", "MBP", "NEURO_HEAVY", "NEURO_LIGHT", "OMP", "PGP9_5", "RB_CALRETININ", "S100", "SYNAPTOPHYSIN", "TAU", "TOMATO_LECTIN", "TYR_HYDROXYLASE", "UEA_LECTIN") temp3 <- matrix(as.numeric(unlist(temp2)),dim(temp2)[1],dim(temp2)[2]) temp3 <- ifelse(temp3==1,0,1) dimnames(temp3) <- dimnames(temp2) col.2.use <- rainbow(length(tau.hits)) hhh <- heatmap.2(as.matrix(temp3),density.info="none",labRow=dimnames(temp3)[[1]],labCol="",scale="none",Rowv=TRUE,Colv=TRUE,col=c(0,1),ColSideColors=col.2.use,key=FALSE,trace="both",linecol=NULL,tracecol="gray",margins = c(5, 10)) temp <- hhh[2][[1]] names(temp) <- col.2.use temp <- sort(temp) col.2.use <- names(temp) temp <- hhh[2][[1]] names(temp) <- c(1:26) temp <- sort(temp) combo <- names(temp) hhh <- heatmap.2(as.matrix(temp3),density.info="none",labCol=combo,labRow=dimnames(temp3)[[1]],scale="none",Rowv=TRUE,Colv=TRUE,col=c(0,1),ColSideColors=col.2.use,key=FALSE,trace="both",linecol=NULL,tracecol="gray",margins = c(5, 10),xlab="Label Combinations (TAU+, Kruskal-Wallis P < 0.05)",adjCol = c(NA,0.4)) #tiff("TAU_String_HeatMap_20200930.tiff",res=300,width = 6, height = 3, units = "in") svg("TAU_String_HeatMap_20200930.svg",width = 12, height = 5) hhh <- heatmap.2(as.matrix(temp3),density.info="none",labCol=combo,labRow=dimnames(temp3)[[1]],scale="none",Rowv=TRUE,Colv=TRUE,col=c(0,1),ColSideColors=col.2.use,key=FALSE,trace="both",linecol=NULL,tracecol="gray",margins = c(5, 10),xlab="Label Combinations (TAU+, Kruskal-Wallis P < 0.05)",adjCol = c(NA,0.4)) dev.off() tau.hits <- dimnames(temp3)[[2]][hhh[[2]]] col.2.use <- rainbow(length(tau.hits)) for (t in 1:length(tau.hits)) { print(t) print(length(tau.hits)) temp <- tau.hits[t] temp <- working[working==temp] temp <- names(temp) temptemp <- strsplit(temp,"_Pos_") temptemp <- as.data.frame(temptemp) temptemp <- t(temptemp) dimnames(temptemp)[[1]] <- temp temp <- as.character(temptemp[,2]) temp <- strsplit(temp,"X") temp <- as.data.frame(temp) temp <- t(temp) temptemp <- cbind(temptemp,temp) dimnames(temptemp)[[2]] <- c("Sample","Location","Xpos","Ypos") #pdf(paste(c("TAU_",tau.hits[t],".pdf"),collapse="",sep=""),width = 28950/1000, height = 6030/1000) pdf(paste(c("TAU_String_Combination_",t,".pdf"),collapse="",sep=""),width = 28950/1000, height = 6030/1000) # AZ_109_146 new.x <- as.numeric(unlist(plot.bulb.locations.AZ109[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ109[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_109_146") if(length(grep("AZ_109_146",temptemp[,1]))>0) { if(length(grep("AZ_109_146",temptemp[,1]))==1) { temp <- temptemp[grep("AZ_109_146",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("AZ_109_146",temptemp[,1]))>1) { temp <- temptemp[grep("AZ_109_146",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # AZ_84_145 new.x <- as.numeric(unlist(plot.bulb.locations.AZ84[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ84[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_84_145") if(length(grep("AZ_84_145",temptemp[,1]))>0) { if(length(grep("AZ_84_145",temptemp[,1]))==1) { temp <- temptemp[grep("AZ_84_145",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("AZ_84_145",temptemp[,1]))>1) { temp <- temptemp[grep("AZ_84_145",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # AZ_90_242 new.x <- as.numeric(unlist(plot.bulb.locations.AZ90[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ90[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_90_242") if(length(grep("AZ_90_242",temptemp[,1]))>0) { if(length(grep("AZ_90_242",temptemp[,1]))==1) { temp <- temptemp[grep("AZ_90_242",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("AZ_90_242",temptemp[,1]))>1) { temp <- temptemp[grep("AZ_90_242",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # AZ_99_140 new.x <- as.numeric(unlist(plot.bulb.locations.AZ99[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ99[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_99_140") if(length(grep("AZ_99_140",temptemp[,1]))>0) { if(length(grep("AZ_99_140",temptemp[,1]))==1) { temp <- temptemp[grep("AZ_99_140",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("AZ_99_140",temptemp[,1]))>1) { temp <- temptemp[grep("AZ_99_140",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # AZ_251_146 new.x <- as.numeric(unlist(plot.bulb.locations.AZH251[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZH251[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_251_146") if(length(grep("AZ_251_146",temptemp[,1]))>0) { if(length(grep("AZ_251_146",temptemp[,1]))==1) { temp <- temptemp[grep("AZ_251_146",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("AZ_251_146",temptemp[,1]))>1) { temp <- temptemp[grep("AZ_251_146",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # Control_H190_260 new.x <- as.numeric(unlist(plot.bulb.locations.ControlH190[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlH190[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_H190_260") if(length(grep("Control_H190_260",temptemp[,1]))>0) { if(length(grep("Control_H190_260",temptemp[,1]))==1) { temp <- temptemp[grep("Control_H190_260",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("Control_H190_260",temptemp[,1]))>1) { temp <- temptemp[grep("Control_H190_260",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # Control_H250_185 new.x <- as.numeric(unlist(plot.bulb.locations.ControlH250[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlH250[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_H250_185") if(length(grep("Control_H250_185",temptemp[,1]))>0) { if(length(grep("Control_H250_185",temptemp[,1]))==1) { temp <- temptemp[grep("Control_H250_185",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("Control_H250_185",temptemp[,1]))>1) { temp <- temptemp[grep("Control_H250_185",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # Control_OFB57_194 new.x <- as.numeric(unlist(plot.bulb.locations.ControlOFB57[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlOFB57[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_OFB57_194") if(length(grep("Control_OFB57_194",temptemp[,1]))>0) { if(length(grep("Control_OFB57_194",temptemp[,1]))==1) { temp <- temptemp[grep("Control_OFB57_194",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("Control_OFB57_194",temptemp[,1]))>1) { temp <- temptemp[grep("Control_OFB57_194",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # Control_OFB6A_107 new.x <- as.numeric(unlist(plot.bulb.locations.ControlOFB6a[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlOFB6a[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_OFB6A_107") if(length(grep("Control_OFB6A_107",temptemp[,1]))>0) { if(length(grep("Control_OFB6A_107",temptemp[,1]))==1) { temp <- temptemp[grep("Control_OFB6A_107",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("Control_OFB6A_107",temptemp[,1]))>1) { temp <- temptemp[grep("Control_OFB6A_107",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # PD_52_247 new.x <- as.numeric(unlist(plot.bulb.locations.PD52[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD52[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_52_247") if(length(grep("PD_52_247",temptemp[,1]))>0) { if(length(grep("PD_52_247",temptemp[,1]))==1) { temp <- temptemp[grep("PD_52_247",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("PD_52_247",temptemp[,1]))>1) { temp <- temptemp[grep("PD_52_247",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # PD_56_236 new.x <- as.numeric(unlist(plot.bulb.locations.PD56[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD56[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_56_236") if(length(grep("PD_56_236",temptemp[,1]))>0) { if(length(grep("PD_56_236",temptemp[,1]))==1) { temp <- temptemp[grep("PD_56_236",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("PD_56_236",temptemp[,1]))>1) { temp <- temptemp[grep("PD_56_236",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # PD_58_22 new.x <- as.numeric(unlist(plot.bulb.locations.PD58[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD58[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_58_22") if(length(grep("PD_58_22",temptemp[,1]))>0) { if(length(grep("PD_58_22",temptemp[,1]))==1) { temp <- temptemp[grep("PD_58_22",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("PD_58_22",temptemp[,1]))>1) { temp <- temptemp[grep("PD_58_22",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # PD_77_197 new.x <- as.numeric(unlist(plot.bulb.locations.PD77[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD77[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_77_197") if(length(grep("PD_77_197",temptemp[,1]))>0) { if(length(grep("PD_77_197",temptemp[,1]))==1) { temp <- temptemp[grep("PD_77_197",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("PD_77_197",temptemp[,1]))>1) { temp <- temptemp[grep("PD_77_197",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } # PD_79_201 new.x <- as.numeric(unlist(plot.bulb.locations.PD79[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD79[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_79_201") if(length(grep("PD_79_201",temptemp[,1]))>0) { if(length(grep("PD_79_201",temptemp[,1]))==1) { temp <- temptemp[grep("PD_79_201",temptemp[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } if(length(grep("PD_79_201",temptemp[,1]))>1) { temp <- temptemp[grep("PD_79_201",temptemp[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use[t]) } } dev.off() } tau.catch.all <- NULL for (t in 1:length(tau.hits)) { print(t) print(length(tau.hits)) temp <- tau.hits[t] temp <- working[working==temp] temp <- names(temp) temptemp <- strsplit(temp,"_Pos_") temptemp <- as.data.frame(temptemp) temptemp <- t(temptemp) dimnames(temptemp)[[1]] <- temp temp <- as.character(temptemp[,2]) temp <- strsplit(temp,"X") temp <- as.data.frame(temp) temp <- t(temp) temptemp <- cbind(temptemp,temp) temptemp <- cbind(temptemp,col.2.use[t]) dimnames(temptemp)[[2]] <- c("Sample","Location","Xpos","Ypos","Color") tau.catch.all <- rbind(tau.catch.all,temptemp) } pdf("TAU_All_String_Hits.pdf",width = 28950/1000, height = 6030/1000) # AZ_109_146 new.x <- as.numeric(unlist(plot.bulb.locations.AZ109[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ109[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_109_146") if(length(grep("AZ_109_146",tau.catch.all[,1]))>0) { if(length(grep("AZ_109_146",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("AZ_109_146",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("AZ_109_146",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("AZ_109_146",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # AZ_84_145 new.x <- as.numeric(unlist(plot.bulb.locations.AZ84[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ84[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_84_145") if(length(grep("AZ_84_145",tau.catch.all[,1]))>0) { if(length(grep("AZ_84_145",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("AZ_84_145",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("AZ_84_145",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("AZ_84_145",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # AZ_90_242 new.x <- as.numeric(unlist(plot.bulb.locations.AZ90[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ90[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_90_242") if(length(grep("AZ_90_242",tau.catch.all[,1]))>0) { if(length(grep("AZ_90_242",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("AZ_90_242",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("AZ_90_242",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("AZ_90_242",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # AZ_99_140 new.x <- as.numeric(unlist(plot.bulb.locations.AZ99[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ99[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_99_140") if(length(grep("AZ_99_140",tau.catch.all[,1]))>0) { if(length(grep("AZ_99_140",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("AZ_99_140",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("AZ_99_140",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("AZ_99_140",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # AZ_251_146 new.x <- as.numeric(unlist(plot.bulb.locations.AZH251[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZH251[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_251_146") if(length(grep("AZ_251_146",tau.catch.all[,1]))>0) { if(length(grep("AZ_251_146",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("AZ_251_146",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("AZ_251_146",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("AZ_251_146",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # Control_H190_260 new.x <- as.numeric(unlist(plot.bulb.locations.ControlH190[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlH190[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_H190_260") if(length(grep("Control_H190_260",tau.catch.all[,1]))>0) { if(length(grep("Control_H190_260",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("Control_H190_260",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("Control_H190_260",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("Control_H190_260",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # Control_H250_185 new.x <- as.numeric(unlist(plot.bulb.locations.ControlH250[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlH250[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_H250_185") if(length(grep("Control_H250_185",tau.catch.all[,1]))>0) { if(length(grep("Control_H250_185",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("Control_H250_185",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("Control_H250_185",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("Control_H250_185",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # Control_OFB57_194 new.x <- as.numeric(unlist(plot.bulb.locations.ControlOFB57[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlOFB57[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_OFB57_194") if(length(grep("Control_OFB57_194",tau.catch.all[,1]))>0) { if(length(grep("Control_OFB57_194",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("Control_OFB57_194",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("Control_OFB57_194",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("Control_OFB57_194",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # Control_OFB6A_107 new.x <- as.numeric(unlist(plot.bulb.locations.ControlOFB6a[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlOFB6a[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_OFB6A_107") if(length(grep("Control_OFB6A_107",tau.catch.all[,1]))>0) { if(length(grep("Control_OFB6A_107",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("Control_OFB6A_107",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("Control_OFB6A_107",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("Control_OFB6A_107",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # PD_52_247 new.x <- as.numeric(unlist(plot.bulb.locations.PD52[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD52[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_52_247") if(length(grep("PD_52_247",tau.catch.all[,1]))>0) { if(length(grep("PD_52_247",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("PD_52_247",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("PD_52_247",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("PD_52_247",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # PD_56_236 new.x <- as.numeric(unlist(plot.bulb.locations.PD56[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD56[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_56_236") if(length(grep("PD_56_236",tau.catch.all[,1]))>0) { if(length(grep("PD_56_236",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("PD_56_236",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("PD_56_236",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("PD_56_236",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # PD_58_22 new.x <- as.numeric(unlist(plot.bulb.locations.PD58[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD58[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_58_22") if(length(grep("PD_58_22",tau.catch.all[,1]))>0) { if(length(grep("PD_58_22",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("PD_58_22",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("PD_58_22",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("PD_58_22",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # PD_77_197 new.x <- as.numeric(unlist(plot.bulb.locations.PD77[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD77[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_77_197") if(length(grep("PD_77_197",tau.catch.all[,1]))>0) { if(length(grep("PD_77_197",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("PD_77_197",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("PD_77_197",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("PD_77_197",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } # PD_79_201 new.x <- as.numeric(unlist(plot.bulb.locations.PD79[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD79[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_79_201") if(length(grep("PD_79_201",tau.catch.all[,1]))>0) { if(length(grep("PD_79_201",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("PD_79_201",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("PD_79_201",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("PD_79_201",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } dev.off() # ALL SIGNIF HITS all.signif.hits <- c("0_0_0_0_0_0_0_0_0_0_0_0_0_0_1_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_0_0_0", "0_0_0_0_0_1_0_0_1_0_0_0_1_1_1_1_0_1_0_1_1_0_0_0_0", "0_0_0_0_0_1_0_0_0_0_0_0_0_0_0_1_0_1_0_0_0_0_0_0_0") all.signif.hits <- sort(all.signif.hits) temp1 <- strsplit(all.signif.hits,"_") temp2 <- as.data.frame(temp1) dimnames(temp2)[[2]] <- all.signif.hits dimnames(temp2)[[1]] <- c("ALPHA_SYNUCLEIN", "BETA_AMYLOID", "CALBINDIN", "CD31", "CH_NEUN", "CNPASE", "COLLAGEN_IV", "DAPI", "GFAP", "HISTONES", "HLADR", "IBA1", "MAP2", "MBP", "NEURO_HEAVY", "NEURO_LIGHT", "OMP", "PGP9_5", "RB_CALRETININ", "S100", "SYNAPTOPHYSIN", "TAU", "TOMATO_LECTIN", "TYR_HYDROXYLASE", "UEA_LECTIN") temp3 <- matrix(as.numeric(unlist(temp2)),dim(temp2)[1],dim(temp2)[2]) temp3 <- ifelse(temp3==1,0,1) dimnames(temp3) <- dimnames(temp2) col.2.use <- rainbow(length(all.signif.hits)) hhh <- heatmap.2(as.matrix(temp3),density.info="none",labRow=dimnames(temp3)[[1]],labCol="",scale="none",Rowv=TRUE,Colv=TRUE,col=c(0,1),ColSideColors=col.2.use,key=FALSE,trace="both",linecol=NULL,tracecol="gray",margins = c(5, 10)) temp <- hhh[2][[1]] names(temp) <- col.2.use temp <- sort(temp) col.2.use <- names(temp) temp <- hhh[2][[1]] names(temp) <- c(1:324) temp <- sort(temp) combo <- names(temp) hhh <- heatmap.2(as.matrix(temp3),density.info="none",labCol="",labRow=dimnames(temp3)[[1]],scale="none",Rowv=TRUE,Colv=TRUE,col=c(0,1),key=FALSE,trace="both",linecol=NULL,tracecol="gray",margins = c(5, 10),xlab="Label Combinations (Kruskal-Wallis P < 0.05)",adjCol = c(NA,0.4)) #tiff("TAU_String_HeatMap_20200930.tiff",res=300,width = 6, height = 3, units = "in") svg("All_Signif_String_HeatMap_20200930.svg",width = 12, height = 5) hhh <- heatmap.2(as.matrix(temp3),density.info="none",labCol="",labRow=dimnames(temp3)[[1]],scale="none",Rowv=TRUE,Colv=TRUE,col=c(0,1),key=FALSE,trace="both",linecol=NULL,tracecol="gray",margins = c(5, 10),xlab="Label Combinations (Kruskal-Wallis P < 0.05)",adjCol = c(NA,0.4)) dev.off() tau.catch.all <- NULL for (t in 1:length(tau.hits)) { print(t) print(length(tau.hits)) temp <- tau.hits[t] temp <- working[working==temp] temp <- names(temp) temptemp <- strsplit(temp,"_Pos_") temptemp <- as.data.frame(temptemp) temptemp <- t(temptemp) dimnames(temptemp)[[1]] <- temp temp <- as.character(temptemp[,2]) temp <- strsplit(temp,"X") temp <- as.data.frame(temp) temp <- t(temp) temptemp <- cbind(temptemp,temp) dimnames(temptemp)[[2]] <- c("Sample","Location","Xpos","Ypos") tau.catch.all <- rbind(tau.catch.all,temptemp) } pdf("TAU_Catch_All_Hits.pdf") # AZ_109_146 new.x <- as.numeric(unlist(plot.bulb.locations.AZ109[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ109[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_109_146") if(length(grep("AZ_109_146",tau.catch.all[,1]))>0) { if(length(grep("AZ_109_146",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("AZ_109_146",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("AZ_109_146",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("AZ_109_146",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } # AZ_84_145 new.x <- as.numeric(unlist(plot.bulb.locations.AZ84[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ84[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_84_145") if(length(grep("AZ_84_145",tau.catch.all[,1]))>0) { if(length(grep("AZ_84_145",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("AZ_84_145",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("AZ_84_145",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("AZ_84_145",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } # AZ_90_242 new.x <- as.numeric(unlist(plot.bulb.locations.AZ90[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ90[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_90_242") if(length(grep("AZ_90_242",tau.catch.all[,1]))>0) { if(length(grep("AZ_90_242",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("AZ_90_242",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("AZ_90_242",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("AZ_90_242",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } # AZ_99_140 new.x <- as.numeric(unlist(plot.bulb.locations.AZ99[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ99[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_99_140") if(length(grep("AZ_99_140",tau.catch.all[,1]))>0) { if(length(grep("AZ_99_140",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("AZ_99_140",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("AZ_99_140",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("AZ_99_140",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } # AZ_251_146 new.x <- as.numeric(unlist(plot.bulb.locations.AZH251[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZH251[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_251_146") if(length(grep("AZ_251_146",tau.catch.all[,1]))>0) { if(length(grep("AZ_251_146",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("AZ_251_146",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("AZ_251_146",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("AZ_251_146",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } # Control_H190_260 new.x <- as.numeric(unlist(plot.bulb.locations.ControlH190[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlH190[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_H190_260") if(length(grep("Control_H190_260",tau.catch.all[,1]))>0) { if(length(grep("Control_H190_260",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("Control_H190_260",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("Control_H190_260",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("Control_H190_260",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } # Control_H250_185 new.x <- as.numeric(unlist(plot.bulb.locations.ControlH250[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlH250[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_H250_185") if(length(grep("Control_H250_185",tau.catch.all[,1]))>0) { if(length(grep("Control_H250_185",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("Control_H250_185",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("Control_H250_185",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("Control_H250_185",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } # Control_OFB57_194 new.x <- as.numeric(unlist(plot.bulb.locations.ControlOFB57[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlOFB57[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_OFB57_194") if(length(grep("Control_OFB57_194",tau.catch.all[,1]))>0) { if(length(grep("Control_OFB57_194",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("Control_OFB57_194",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("Control_OFB57_194",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("Control_OFB57_194",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } # Control_OFB6A_107 new.x <- as.numeric(unlist(plot.bulb.locations.ControlOFB6a[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.ControlOFB6a[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Control_OFB6A_107") if(length(grep("Control_OFB6A_107",tau.catch.all[,1]))>0) { if(length(grep("Control_OFB6A_107",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("Control_OFB6A_107",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("Control_OFB6A_107",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("Control_OFB6A_107",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } # PD_52_247 new.x <- as.numeric(unlist(plot.bulb.locations.PD52[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD52[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_52_247") if(length(grep("PD_52_247",tau.catch.all[,1]))>0) { if(length(grep("PD_52_247",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("PD_52_247",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("PD_52_247",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("PD_52_247",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } # PD_56_236 new.x <- as.numeric(unlist(plot.bulb.locations.PD56[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD56[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_56_236") if(length(grep("PD_56_236",tau.catch.all[,1]))>0) { if(length(grep("PD_56_236",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("PD_56_236",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("PD_56_236",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("PD_56_236",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } # PD_58_22 new.x <- as.numeric(unlist(plot.bulb.locations.PD58[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD58[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_58_22") if(length(grep("PD_58_22",tau.catch.all[,1]))>0) { if(length(grep("PD_58_22",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("PD_58_22",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("PD_58_22",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("PD_58_22",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } # PD_77_197 new.x <- as.numeric(unlist(plot.bulb.locations.PD77[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD77[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_77_197") if(length(grep("PD_77_197",tau.catch.all[,1]))>0) { if(length(grep("PD_77_197",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("PD_77_197",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("PD_77_197",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("PD_77_197",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } # PD_79_201 new.x <- as.numeric(unlist(plot.bulb.locations.PD79[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.PD79[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="PD_79_201") if(length(grep("PD_79_201",tau.catch.all[,1]))>0) { if(length(grep("PD_79_201",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("PD_79_201",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } if(length(grep("PD_79_201",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("PD_79_201",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col="black") } } dev.off() /gpfs/gsfs10/users/johnsonko/SideProject/Helen/20200811/Analysis_Ready" https://protect-au.mimecast.com/s/c4y2CQnMx5ClAQL8fVgE92?domain=people.cs.uchicago.edu save.session("Current_20201001.RSession") save.image("Current_20201001.RData") load("Current_20201001.RData") HEREHERE ##################################################### # Spatial Analysis ##################################################### all.signif.hits <- c("0_0_0_0_0_0_0_0_0_0_0_0_0_0_1_1_0_1_0_1_0_0_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_0_1_1_1_0_1_0_1_0_0_0_0_0", "0_0_0_0_0_0_0_0_1_0_0_0_1_0_0_0_0_1_0_0_1_1_0_0_0", "0_0_0_0_1_0_0_1_1_1_0_1_1_0_0_1_0_1_0_0_0_0_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_0_0_1_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_1_1_0_0_1_0_0_1_0_0_0_1_0_0_0_0_0", "0_0_0_0_0_0_0_0_1_0_0_0_1_0_0_0_0_0_0_0_0_0_0_1_0", "0_0_0_0_0_0_0_1_1_1_0_0_1_0_0_1_0_0_0_1_0_0_0_0_0", "0_0_0_0_0_0_0_0_1_0_0_0_1_0_0_1_0_1_0_0_1_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_0_0_1_0_0_1_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_1_0_0_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_1_0_1_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_1_0_0_1_0_1_0_0_1_1_0_0_0", "0_0_0_0_0_0_0_0_1_0_0_0_1_0_0_1_0_1_0_0_0_1_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_1_0_1_0_0_1_0_0_0_0", "0_0_0_0_0_0_0_0_0_0_0_0_0_1_0_1_0_1_0_1_0_0_0_0_0", "0_0_0_0_0_0_0_0_0_1_0_0_0_0_0_1_0_1_0_1_0_0_0_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0_0_1_0_0_1_0_1_0_0_0_0_0_0_0_1_0_0_0_0_0_0_0", "0_0_0_0_0_0_0_0_1_0_0_0_1_0_0_1_0_1_0_0_0_0_0_1_0", "0_0_0_0_0_0_1_0_1_0_0_0_1_0_0_1_0_1_0_0_0_0_0_0_0", "0_0_0_0_0_1_0_0_0_0_0_0_0_1_1_1_0_1_0_0_1_0_0_0_0", "0_0_0_0_0_1_0_0_1_0_0_0_1_1_1_1_0_1_0_1_1_0_0_0_0", "0_0_0_0_0_1_0_0_0_0_0_0_0_0_0_1_0_1_0_0_0_0_0_0_0") all.signif.hits <- sort(all.signif.hits) library(Rcpp) library(dbscan) # https://protect-au.mimecast.com/s/TWTnCRONy5u0m6XJup59Rs?domain=cran.r-project.org # https://protect-au.mimecast.com/s/K7XKCVARD0TkwJ87c8OGKl?domain=datanovia.com # Sample_AZ_109_146_Pos_ temp1 <- working[grep("Sample_AZ_109_146_Pos_",names(working))] temp2 <- strsplit(names(temp1),"Pos_") temp3 <- as.data.frame(temp2) temp3 <- t(temp3) temp3 <- strsplit(temp3[,2],"X") temp3 <- as.data.frame(temp3) temp3 <- t(temp3) dimnames(temp3) <- NULL temp3 <- cbind(as.character(temp1),temp3) temp4 <- NULL for (i in 1:length(all.signif.hits)) { print(i) print(length(all.signif.hits)) temp <- all.signif.hits[i] temp <- grep(temp,temp3[,1]) if(length(temp)>0) { temp1 <- temp3[temp,] temp4 <- rbind(temp4,temp1) } } temp5 <- cbind(as.numeric(temp4[,2]),(-1*as.numeric(temp4[,3]))) pdf("Signif_String_kNN_Inspection_AZ_109_146.pdf",width = 28950/1000, height = 6030/1000) kNNdistplot(temp5, k = 3) kkk <- kNNdist(temp5, k = 3) kkk <- sort(unique(kkk)) for(i in 1:length(kkk)) { abline(h=kkk[i],col=2,lty=2) } dev.off() final.temp7 <- temp4 pdf("Signif_String_DBSCAN_Clustering_AZ_109_146.pdf",width = 28950/1000, height = 6030/1000) for(i in 1:length(kkk)) { temp6 <- dbscan(temp5,borderPoints = FALSE, minPts=3,eps=kkk[i]) temp7 <- cbind(temp5,temp6$cluster) final.temp7 <- cbind(final.temp7,temp6$cluster) new.x <- as.numeric(unlist(plot.bulb.locations.AZ109[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ109[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main=as.character(kkk[i])) num.clust <- (length(unique(sort(temp6$cluster))))-1 col.2.use <- rainbow(num.clust) points(temp7[,1],temp7[,2], col = "black",pch=15) for (j in 1:length(col.2.use)) { if(sum(temp7[,3]==j)>=2) { temp8 <- temp7[temp7[,3]==j,] points(temp8[,1],temp8[,2],col=col.2.use[j],pch=15) } } } dev.off() dimnames(final.temp7)[[2]] <- c("String","X","Y",as.character(kkk)) write.table(final.temp7,"Signif_String_DBSCAN_Clustering_AZ_109_146.txt",sep="\t") temp6$cluster + 1L) # https://protect-au.mimecast.com/s/TWTnCRONy5u0m6XJup59Rs?domain=cran.r-project.org # AZ_109_146 new.x <- as.numeric(unlist(plot.bulb.locations.AZ109[,1])) new.y <- as.numeric(unlist(plot.bulb.locations.AZ109[,2])) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="AZ_109_146") if(length(grep("AZ_109_146",tau.catch.all[,1]))>0) { if(length(grep("AZ_109_146",tau.catch.all[,1]))==1) { temp <- tau.catch.all[grep("AZ_109_146",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[3])) new.y <- as.numeric(unlist(temp[4])) ccc <- as.character(unlist(temp[5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } if(length(grep("AZ_109_146",tau.catch.all[,1]))>1) { temp <- tau.catch.all[grep("AZ_109_146",tau.catch.all[,1]),] new.x <- as.numeric(unlist(temp[,3])) new.y <- as.numeric(unlist(temp[,4])) ccc <- as.character(unlist(temp[,5])) points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=ccc) } } ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## # By Bulb Seurat Analysis - 20201006 ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## # HEREHERE setwd("/data/johnsonko/SideProject/Helen/20200811/Analysis_Ready") load("Current_20201006.RData") setwd("/data/johnsonko/SideProject/Helen/20200811/Bulb_Locations") final.Bulb.Locations.AZ109 <- read.table("Bulb_Locations_AZ109.txt") # AZ_109_146 final.Bulb.Locations.AZ84 <- read.table("Bulb_Locations_AZ84.txt") # AZ_84_145 final.Bulb.Locations.AZ90 <- read.table("Bulb_Locations_AZ90.txt") # AZ_90_242 final.Bulb.Locations.AZ99 <- read.table("Bulb_Locations_AZ99.txt") # AZ_99_140 final.Bulb.Locations.H251 <- read.table("Bulb_Locations_H251.txt") # AZ_251_146 final.Bulb.Locations.H190 <- read.table("Bulb_Locations_H190.txt") # Control_H190_260 final.Bulb.Locations.H250 <- read.table("Bulb_Locations_H250.txt") # Control_H250_185 final.Bulb.Locations.OFB57 <- read.table("Bulb_Locations_OFB57.txt") # Control_OFB57_194 final.Bulb.Locations.OFB6a <- read.table("Bulb_Locations_OFB6a.txt") # Control_OFB6A_107 final.Bulb.Locations.PD52 <- read.table("Bulb_Locations_PD52.txt") # PD_52_247 final.Bulb.Locations.PD56 <- read.table("Bulb_Locations_PD56.txt") # PD_56_236 final.Bulb.Locations.PD58 <- read.table("Bulb_Locations_PD58.txt") # PD_58_22 final.Bulb.Locations.PD77 <- read.table("Bulb_Locations_PD77.txt") # PD_77_197 final.Bulb.Locations.PD79 <- read.table("Bulb_Locations_PD79.txt") # PD_79_201 setwd("/data/johnsonko/SideProject/Helen/20200811/Analysis_Ready") Final_Analysis_Ready_Counts_AZ_109_146 <- read.table("Final_Analysis_Ready_Counts_AZ_109_146.txt",header=T) Final_Analysis_Ready_Counts_AZ_251_146 <- read.table("Final_Analysis_Ready_Counts_AZ_251_146.txt",header=T) Final_Analysis_Ready_Counts_AZ_84_145 <- read.table("Final_Analysis_Ready_Counts_AZ_84_145.txt",header=T) Final_Analysis_Ready_Counts_AZ_90_242 <- read.table("Final_Analysis_Ready_Counts_AZ_90_242.txt",header=T) Final_Analysis_Ready_Counts_AZ_99_140 <- read.table("Final_Analysis_Ready_Counts_AZ_99_140.txt",header=T) Final_Analysis_Ready_Counts_Control_H190_260 <- read.table("Final_Analysis_Ready_Counts_Control_H190_260.txt",header=T) Final_Analysis_Ready_Counts_Control_H250_185 <- read.table("Final_Analysis_Ready_Counts_Control_H250_185.txt",header=T) Final_Analysis_Ready_Counts_Control_OFB57_194 <- read.table("Final_Analysis_Ready_Counts_Control_OFB57_194.txt",header=T) Final_Analysis_Ready_Counts_Control_OFB6A_107 <- read.table("Final_Analysis_Ready_Counts_Control_OFB6A_107.txt",header=T) Final_Analysis_Ready_Counts_PD_52_247 <- read.table("Final_Analysis_Ready_Counts_PD_52_247.txt",header=T) Final_Analysis_Ready_Counts_PD_56_236 <- read.table("Final_Analysis_Ready_Counts_PD_56_236.txt",header=T) Final_Analysis_Ready_Counts_PD_58_229 <- read.table("Final_Analysis_Ready_Counts_PD_58_229.txt",header=T) Final_Analysis_Ready_Counts_PD_77_197 <- read.table("Final_Analysis_Ready_Counts_PD_77_197.txt",header=T) Final_Analysis_Ready_Counts_PD_79_201 <- read.table("Final_Analysis_Ready_Counts_PD_79_201.txt",header=T) ttt <- c("Final_Analysis_Ready_Counts_AZ_109_146", "Final_Analysis_Ready_Counts_AZ_251_146", "Final_Analysis_Ready_Counts_AZ_84_145", "Final_Analysis_Ready_Counts_AZ_90_242", "Final_Analysis_Ready_Counts_AZ_99_140", "Final_Analysis_Ready_Counts_Control_H190_260", "Final_Analysis_Ready_Counts_Control_H250_185", "Final_Analysis_Ready_Counts_Control_OFB57_194", "Final_Analysis_Ready_Counts_Control_OFB6A_107", "Final_Analysis_Ready_Counts_PD_52_247", "Final_Analysis_Ready_Counts_PD_56_236", "Final_Analysis_Ready_Counts_PD_58_229", "Final_Analysis_Ready_Counts_PD_77_197", "Final_Analysis_Ready_Counts_PD_79_201") ppp <- c("AZ_109_146", "AZ_251_146", "AZ_84_145", "AZ_90_242", "AZ_99_140", "Control_H190_260", "Control_H250_185", "Control_OFB57_194", "Control_OFB6A_107", "PD_52_247", "PD_56_236", "PD_58_229", "PD_77_197", "PD_79_201") bbb <- c("final.Bulb.Locations.AZ109", "final.Bulb.Locations.H251", "final.Bulb.Locations.AZ84", "final.Bulb.Locations.AZ90", "final.Bulb.Locations.AZ99", "final.Bulb.Locations.H190", "final.Bulb.Locations.H250", "final.Bulb.Locations.OFB57", "final.Bulb.Locations.OFB6a", "final.Bulb.Locations.PD52", "final.Bulb.Locations.PD56", "final.Bulb.Locations.PD58", "final.Bulb.Locations.PD77", "final.Bulb.Locations.PD79") setwd("/data/johnsonko/SideProject/Helen/20200811/Analysis_Slides") library(Seurat) library(ggplot2) library(sctransform) library(patchwork) library(slides) library("scales") library(stringr) for (t in 1:length(ttt)) { rm(pbmc) print(t) temp0 <- eval(parse(text=ttt[t])) temp0 <- as.matrix(temp0) temp0 <- round(temp0*100,0) temp1 <- temp0[apply(temp0,1,max)>0,] temp1 <- t(temp1) pbmc <- CreateSeuratObject(counts = temp1) pbmc <- SCTransform(pbmc, verbose = FALSE) pbmc <- RunPCA(pbmc, verbose = FALSE,approx=FALSE) #DimPlot(pbmc,reduction="pca",label=FALSE) e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc <- RunUMAP(pbmc, dims = 1:dims2use, verbose = FALSE) #DimPlot(pbmc,reduction="umap",label=FALSE) pbmc <- FindNeighbors(pbmc, dims = 1:dims2use, verbose = FALSE) pbmc <- FindClusters(pbmc, verbose = FALSE) write.table(table(pbmc@meta.data$seurat_clusters),paste(c("Cluster_Bin_Counts_",ppp[t],".txt"),sep="",collapse="")) tiff(paste(c("UMAP_Plot_Label_Yes_Legend_Yes_",ppp[t],".tiff"),sep="",collapse="")) print(DimPlot(pbmc,reduction="umap",label=TRUE)) dev.off() tiff(paste(c("UMAP_Plot_Label_Yes_Legend_No_",ppp[t],".tiff"),sep="",collapse="")) print(DimPlot(pbmc,reduction="umap",label = TRUE) + NoLegend()) dev.off() tiff(paste(c("UMAP_Plot_Label_No_Legend_No_",ppp[t],".tiff"),sep="",collapse="")) print(DimPlot(pbmc,reduction="umap",label = FALSE) + NoLegend()) dev.off() tiff(paste(c("UMAP_Plot_Label_No_Legend_Yes_",ppp[t],".tiff"),sep="",collapse="")) print(DimPlot(pbmc,reduction="umap",label = FALSE)) dev.off() if (length(grep("ALPHA-SYNUCLEIN",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_ALPHA_SYNUCLEIN_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("ALPHA-SYNUCLEIN"))) dev.off() tiff(paste(c("Violin_Plot_ALPHA_SYNUCLEIN_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("ALPHA-SYNUCLEIN")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_ALPHA_SYNUCLEIN_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("ALPHA-SYNUCLEIN"))) dev.off() } if (length(grep("BETA-AMYLOID",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_BETA_AMYLOID_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("BETA-AMYLOID"))) dev.off() tiff(paste(c("Violin_Plot_BETA_AMYLOID_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("BETA-AMYLOID")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_BETA_AMYLOID_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("BETA-AMYLOID"))) dev.off() } if (length(grep("CALBINDIN",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_CALBINDIN_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("CALBINDIN"))) dev.off() tiff(paste(c("Violin_Plot_CALBINDIN_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("CALBINDIN")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_CALBINDIN_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("CALBINDIN"))) dev.off() } if (length(grep("CH-NEUN",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_CH_NEUN_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("CH-NEUN"))) dev.off() tiff(paste(c("Violin_Plot_CH_NEUN_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("CH-NEUN")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_CH_NEUN_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("CH-NEUN"))) dev.off() } if (length(grep("CNPASE",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_CNPASE_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("CNPASE"))) dev.off() tiff(paste(c("Violin_Plot_CNPASE_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("CNPASE")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_CNPASE_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("CNPASE"))) dev.off() } if (length(grep("COLLAGEN-IV",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_COLLAGEN_IV_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("COLLAGEN-IV"))) dev.off() tiff(paste(c("Violin_Plot_COLLAGEN_IV_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("COLLAGEN-IV")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_COLLAGEN_IV_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("COLLAGEN-IV"))) dev.off() } if (length(grep("DAPI",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_DAPI_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("DAPI"))) dev.off() tiff(paste(c("Violin_Plot_DAPI_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("DAPI")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_DAPI_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("DAPI"))) dev.off() } if (length(grep("GFAP",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_GFAP_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("GFAP"))) dev.off() tiff(paste(c("Violin_Plot_GFAP_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("GFAP")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_GFAP_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("GFAP"))) dev.off() } if (length(grep("HISTONES",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_HISTONES_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("HISTONES"))) dev.off() tiff(paste(c("Violin_Plot_HISTONES_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("HISTONES")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_HISTONES_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("HISTONES"))) dev.off() } if (length(grep("HLADR",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_HLADR_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("HLADR"))) dev.off() tiff(paste(c("Violin_Plot_HLADR_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("HLADR")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_HLADR_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("HLADR"))) dev.off() } if (length(grep("IBA1",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_IBA1_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("IBA1"))) dev.off() tiff(paste(c("Violin_Plot_IBA1_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("IBA1")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_IBA1_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("IBA1"))) dev.off() } if (length(grep("MAP2",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_MAP2_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("MAP2"))) dev.off() tiff(paste(c("Violin_Plot_MAP2_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("MAP2")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_MAP2_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("MAP2"))) dev.off() } if (length(grep("MBP",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_MBP_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("MBP"))) dev.off() tiff(paste(c("Violin_Plot_MBP_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("MBP")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_MBP_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("MBP"))) dev.off() } if (length(grep("NEURO-HEAVY",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_NEURO_HEAVY_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("NEURO-HEAVY"))) dev.off() tiff(paste(c("Violin_Plot_NEURO_HEAVY_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("NEURO-HEAVY")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_NEURO_HEAVY_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("NEURO-HEAVY"))) dev.off() } if (length(grep("NEURO-LIGHT",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_NEURO_LIGHT_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("NEURO-LIGHT"))) dev.off() tiff(paste(c("Violin_Plot_NEURO_LIGHT_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("NEURO-LIGHT")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_NEURO_LIGHT_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("NEURO-LIGHT"))) dev.off() } if (length(grep("OMP",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_OMP_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("OMP"))) dev.off() tiff(paste(c("Violin_Plot_OMP_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("OMP")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_OMP_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("OMP"))) dev.off() } if (length(grep("PGP9-5",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_PGP9_5_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("PGP9-5"))) dev.off() tiff(paste(c("Violin_Plot_PGP9_5_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("PGP9-5")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_PGP9_5_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("PGP9-5"))) dev.off() } if (length(grep("RB-CALRETININ",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_RB_CALRETININ_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("RB-CALRETININ"))) dev.off() tiff(paste(c("Violin_Plot_RB_CALRETININ_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("RB-CALRETININ")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_RB_CALRETININ_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("RB-CALRETININ"))) dev.off() } if (length(grep("S100",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_S100_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("S100"))) dev.off() tiff(paste(c("Violin_Plot_S100_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("S100")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_S100_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("S100"))) dev.off() } if (length(grep("SYNAPTOPHYSIN",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_SYNAPTOPHYSIN_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("SYNAPTOPHYSIN"))) dev.off() tiff(paste(c("Violin_Plot_SYNAPTOPHYSIN_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("SYNAPTOPHYSIN")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_SYNAPTOPHYSIN_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("SYNAPTOPHYSIN"))) dev.off() } if (length(grep("TAU",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_TAU_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("TAU"))) dev.off() tiff(paste(c("Violin_Plot_TAU_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("TAU")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_TAU_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("TAU"))) dev.off() } if (length(grep("TOMATO-LECTIN",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_TOMATO_LECTIN_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("TOMATO-LECTIN"))) dev.off() tiff(paste(c("Violin_Plot_TOMATO_LECTIN_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("TOMATO-LECTIN")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_TOMATO_LECTIN_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("TOMATO-LECTIN"))) dev.off() } if (length(grep("TYR-HYDROXYLASE",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_TYR_HYDROXYLASE_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("TYR-HYDROXYLASE"))) dev.off() tiff(paste(c("Violin_Plot_TYR_HYDROXYLASE_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("TYR-HYDROXYLASE")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_TYR_HYDROXYLASE_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("TYR-HYDROXYLASE"))) dev.off() } if (length(grep("UEA-LECTIN",rownames(pbmc)))>0) { tiff(paste(c("Feature_Plot_UEA_LECTIN_",ppp[t],".tiff"),sep="",collapse="")) print(FeaturePlot(pbmc, features = c("UEA-LECTIN"))) dev.off() tiff(paste(c("Violin_Plot_UEA_LECTIN_",ppp[t],".tiff"),sep="",collapse="")) print(VlnPlot(pbmc, features = c("UEA-LECTIN")) + NoLegend()) dev.off() tiff(paste(c("Ridge_Plot_UEA_LECTIN_",ppp[t],".tiff"),sep="",collapse="")) print(RidgePlot(pbmc, features = c("UEA-LECTIN"))) dev.off() } tiff(paste(c("DotPlot_",ppp[t],".tiff"),sep="",collapse="")) print(DotPlot(pbmc, features = rownames(pbmc)) + RotatedAxis()) dev.off() hex_codes1 <- hue_pal()(length(table(pbmc@meta.data$seurat_clusters))) pdf(paste(c("Reconstructed_Slide_Plots_",ppp[t],".pdf"),sep="",collapse=""),width = 28950/1000, height = 6030/1000) sr0 <- eval(parse(text=bbb[t])) sr1 <- dimnames(sr0)[[1]] sr2 <- NULL for (j in 1:length(sr1)) { sr3 <- strsplit(sr1[j], "@")[[1]][2] sr3 <- strsplit(sr3, "X")[[1]] sr2 <- rbind(sr2,as.numeric(sr3)) } new.x <- as.numeric(sr2[,1]) new.y <- as.numeric(sr2[,2]) print(plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Bulb_Detected_Bins")) print(plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="All_Cluster_Overlay")) ssr1 <- colnames(pbmc) ssr2 <- as.numeric(unlist(pbmc@meta.data$seurat_clusters))-1 names(ssr2) <- ssr1 for (i in 1:length(table(pbmc@meta.data$seurat_clusters))) { sssr1 <- names(ssr2[ssr2==(i-1)]) sssr2 <- NULL for (j in 1:length(sssr1)) { sssr3 <- strsplit(sssr1[j], "X")[[1]] sssr2 <- rbind(sssr2,as.numeric(sssr3)) } newnew.x <- as.numeric(sssr2[,1]) newnew.y <- as.numeric(sssr2[,2]) print(points(as.numeric(newnew.x),-1*as.numeric(newnew.y),cex=1,pch=15,col=hex_codes1[i])) } ssr1 <- colnames(pbmc) ssr2 <- as.numeric(unlist(pbmc@meta.data$seurat_clusters))-1 names(ssr2) <- ssr1 for (i in 1:length(table(pbmc@meta.data$seurat_clusters))) { sssr1 <- names(ssr2[ssr2==(i-1)]) sssr2 <- NULL for (j in 1:length(sssr1)) { sssr3 <- strsplit(sssr1[j], "X")[[1]] sssr2 <- rbind(sssr2,as.numeric(sssr3)) } print(plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main=as.character(i-1))) newnew.x <- as.numeric(sssr2[,1]) newnew.y <- as.numeric(sssr2[,2]) print(points(as.numeric(newnew.x),-1*as.numeric(newnew.y),cex=1,pch=15,col=hex_codes1[i])) } dev.off() keep.it <- ppp[t] keep.it <- str_replace_all(keep.it,"_",".") eval(parse(text=paste(c("pbmc.",keep.it," <- pbmc"),collapse="",sep=""))) } save.image("Current_20201006.RData") ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## # Multi Cluster Overlay 20201204 ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## setwd("/data/johnsonko/SideProject/Helen/20200811/Bulb_Locations") final.Bulb.Locations.AZ109 <- read.table("Bulb_Locations_AZ109.txt") # AZ_109_146 final.Bulb.Locations.AZ84 <- read.table("Bulb_Locations_AZ84.txt") # AZ_84_145 final.Bulb.Locations.AZ90 <- read.table("Bulb_Locations_AZ90.txt") # AZ_90_242 final.Bulb.Locations.AZ99 <- read.table("Bulb_Locations_AZ99.txt") # AZ_99_140 final.Bulb.Locations.H251 <- read.table("Bulb_Locations_H251.txt") # AZ_251_146 final.Bulb.Locations.H190 <- read.table("Bulb_Locations_H190.txt") # Control_H190_260 final.Bulb.Locations.H250 <- read.table("Bulb_Locations_H250.txt") # Control_H250_185 final.Bulb.Locations.OFB57 <- read.table("Bulb_Locations_OFB57.txt") # Control_OFB57_194 final.Bulb.Locations.OFB6a <- read.table("Bulb_Locations_OFB6a.txt") # Control_OFB6A_107 final.Bulb.Locations.PD52 <- read.table("Bulb_Locations_PD52.txt") # PD_52_247 final.Bulb.Locations.PD56 <- read.table("Bulb_Locations_PD56.txt") # PD_56_236 final.Bulb.Locations.PD58 <- read.table("Bulb_Locations_PD58.txt") # PD_58_22 final.Bulb.Locations.PD77 <- read.table("Bulb_Locations_PD77.txt") # PD_77_197 final.Bulb.Locations.PD79 <- read.table("Bulb_Locations_PD79.txt") # PD_79_201 setwd("/data/johnsonko/SideProject/Helen/20200811/Analysis_Ready") Final_Analysis_Ready_Counts_AZ_109_146 <- read.table("Final_Analysis_Ready_Counts_AZ_109_146.txt",header=T) Final_Analysis_Ready_Counts_AZ_251_146 <- read.table("Final_Analysis_Ready_Counts_AZ_251_146.txt",header=T) Final_Analysis_Ready_Counts_AZ_84_145 <- read.table("Final_Analysis_Ready_Counts_AZ_84_145.txt",header=T) Final_Analysis_Ready_Counts_AZ_90_242 <- read.table("Final_Analysis_Ready_Counts_AZ_90_242.txt",header=T) Final_Analysis_Ready_Counts_AZ_99_140 <- read.table("Final_Analysis_Ready_Counts_AZ_99_140.txt",header=T) Final_Analysis_Ready_Counts_Control_H190_260 <- read.table("Final_Analysis_Ready_Counts_Control_H190_260.txt",header=T) Final_Analysis_Ready_Counts_Control_H250_185 <- read.table("Final_Analysis_Ready_Counts_Control_H250_185.txt",header=T) Final_Analysis_Ready_Counts_Control_OFB57_194 <- read.table("Final_Analysis_Ready_Counts_Control_OFB57_194.txt",header=T) Final_Analysis_Ready_Counts_Control_OFB6A_107 <- read.table("Final_Analysis_Ready_Counts_Control_OFB6A_107.txt",header=T) Final_Analysis_Ready_Counts_PD_52_247 <- read.table("Final_Analysis_Ready_Counts_PD_52_247.txt",header=T) Final_Analysis_Ready_Counts_PD_56_236 <- read.table("Final_Analysis_Ready_Counts_PD_56_236.txt",header=T) Final_Analysis_Ready_Counts_PD_58_229 <- read.table("Final_Analysis_Ready_Counts_PD_58_229.txt",header=T) Final_Analysis_Ready_Counts_PD_77_197 <- read.table("Final_Analysis_Ready_Counts_PD_77_197.txt",header=T) Final_Analysis_Ready_Counts_PD_79_201 <- read.table("Final_Analysis_Ready_Counts_PD_79_201.txt",header=T) ttt <- c("Final_Analysis_Ready_Counts_AZ_109_146", "Final_Analysis_Ready_Counts_AZ_251_146", "Final_Analysis_Ready_Counts_AZ_84_145", "Final_Analysis_Ready_Counts_AZ_90_242", "Final_Analysis_Ready_Counts_AZ_99_140", "Final_Analysis_Ready_Counts_Control_H190_260", "Final_Analysis_Ready_Counts_Control_H250_185", "Final_Analysis_Ready_Counts_Control_OFB57_194", "Final_Analysis_Ready_Counts_Control_OFB6A_107", "Final_Analysis_Ready_Counts_PD_52_247", "Final_Analysis_Ready_Counts_PD_56_236", "Final_Analysis_Ready_Counts_PD_58_229", "Final_Analysis_Ready_Counts_PD_77_197", "Final_Analysis_Ready_Counts_PD_79_201") ppp <- c("AZ_109_146", "AZ_251_146", "AZ_84_145", "AZ_90_242", "AZ_99_140", "Control_H190_260", "Control_H250_185", "Control_OFB57_194", "Control_OFB6A_107", "PD_52_247", "PD_56_236", "PD_58_229", "PD_77_197", "PD_79_201") bbb <- c("final.Bulb.Locations.AZ109", "final.Bulb.Locations.H251", "final.Bulb.Locations.AZ84", "final.Bulb.Locations.AZ90", "final.Bulb.Locations.AZ99", "final.Bulb.Locations.H190", "final.Bulb.Locations.H250", "final.Bulb.Locations.OFB57", "final.Bulb.Locations.OFB6a", "final.Bulb.Locations.PD52", "final.Bulb.Locations.PD56", "final.Bulb.Locations.PD58", "final.Bulb.Locations.PD77", "final.Bulb.Locations.PD79") setwd("/data/johnsonko/SideProject/Helen/20200811/Analysis_Slides") pbmc <- pbmc.Control.H250.185 # <----------------------------------------------------------------------------------------------------------------------------------HERE t <- 7 hex_codes1 <- hue_pal()(length(table(pbmc@meta.data$seurat_clusters))) pdf(paste(c("Special_Reconstructed_Slide_Plot_20201204",ppp[t],".pdf"),sep="",collapse=""),width = 28950/1000, height = 6030/1000) sr0 <- eval(parse(text=bbb[t])) sr1 <- dimnames(sr0)[[1]] sr2 <- NULL for (j in 1:length(sr1)) { sr3 <- strsplit(sr1[j], "@")[[1]][2] sr3 <- strsplit(sr3, "X")[[1]] sr2 <- rbind(sr2,as.numeric(sr3)) } new.x <- as.numeric(sr2[,1]) new.y <- as.numeric(sr2[,2]) print(plot(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8,main="Select_Cluster_Overlay")) ssr1 <- colnames(pbmc) ssr2 <- as.numeric(unlist(pbmc@meta.data$seurat_clusters))-1 names(ssr2) <- ssr1 sssr1 <- names(ssr2[ssr2==0]) sssr2 <- NULL for (j in 1:length(sssr1)) { sssr3 <- strsplit(sssr1[j], "X")[[1]] sssr2 <- rbind(sssr2,as.numeric(sssr3)) } newnew.x <- as.numeric(sssr2[,1]) newnew.y <- as.numeric(sssr2[,2]) print(points(as.numeric(newnew.x),-1*as.numeric(newnew.y),cex=1,pch=15,col=hex_codes1[0+1])) sssr1 <- names(ssr2[ssr2==1]) sssr2 <- NULL for (j in 1:length(sssr1)) { sssr3 <- strsplit(sssr1[j], "X")[[1]] sssr2 <- rbind(sssr2,as.numeric(sssr3)) } newnew.x <- as.numeric(sssr2[,1]) newnew.y <- as.numeric(sssr2[,2]) print(points(as.numeric(newnew.x),-1*as.numeric(newnew.y),cex=1,pch=15,col=hex_codes1[1+1])) sssr1 <- names(ssr2[ssr2==2]) sssr2 <- NULL for (j in 1:length(sssr1)) { sssr3 <- strsplit(sssr1[j], "X")[[1]] sssr2 <- rbind(sssr2,as.numeric(sssr3)) } newnew.x <- as.numeric(sssr2[,1]) newnew.y <- as.numeric(sssr2[,2]) print(points(as.numeric(newnew.x),-1*as.numeric(newnew.y),cex=1,pch=15,col=hex_codes1[2+1])) sssr1 <- names(ssr2[ssr2==5]) sssr2 <- NULL for (j in 1:length(sssr1)) { sssr3 <- strsplit(sssr1[j], "X")[[1]] sssr2 <- rbind(sssr2,as.numeric(sssr3)) } newnew.x <- as.numeric(sssr2[,1]) newnew.y <- as.numeric(sssr2[,2]) print(points(as.numeric(newnew.x),-1*as.numeric(newnew.y),cex=1,pch=15,col=hex_codes1[5+1])) sssr1 <- names(ssr2[ssr2==6]) sssr2 <- NULL for (j in 1:length(sssr1)) { sssr3 <- strsplit(sssr1[j], "X")[[1]] sssr2 <- rbind(sssr2,as.numeric(sssr3)) } newnew.x <- as.numeric(sssr2[,1]) newnew.y <- as.numeric(sssr2[,2]) print(points(as.numeric(newnew.x),-1*as.numeric(newnew.y),cex=1,pch=15,col=hex_codes1[6+1])) sssr1 <- names(ssr2[ssr2==11]) sssr2 <- NULL for (j in 1:length(sssr1)) { sssr3 <- strsplit(sssr1[j], "X")[[1]] sssr2 <- rbind(sssr2,as.numeric(sssr3)) } newnew.x <- as.numeric(sssr2[,1]) newnew.y <- as.numeric(sssr2[,2]) print(points(as.numeric(newnew.x),-1*as.numeric(newnew.y),cex=1,pch=15,col=hex_codes1[11+1])) sssr1 <- names(ssr2[ssr2==13]) sssr2 <- NULL for (j in 1:length(sssr1)) { sssr3 <- strsplit(sssr1[j], "X")[[1]] sssr2 <- rbind(sssr2,as.numeric(sssr3)) } newnew.x <- as.numeric(sssr2[,1]) newnew.y <- as.numeric(sssr2[,2]) print(points(as.numeric(newnew.x),-1*as.numeric(newnew.y),cex=1,pch=15,col=hex_codes1[13+1])) sssr1 <- names(ssr2[ssr2==15]) sssr2 <- NULL for (j in 1:length(sssr1)) { sssr3 <- strsplit(sssr1[j], "X")[[1]] sssr2 <- rbind(sssr2,as.numeric(sssr3)) } newnew.x <- as.numeric(sssr2[,1]) newnew.y <- as.numeric(sssr2[,2]) print(points(as.numeric(newnew.x),-1*as.numeric(newnew.y),cex=1,pch=15,col=hex_codes1[15+1])) sssr1 <- names(ssr2[ssr2==19]) sssr2 <- NULL for (j in 1:length(sssr1)) { sssr3 <- strsplit(sssr1[j], "X")[[1]] sssr2 <- rbind(sssr2,as.numeric(sssr3)) } newnew.x <- as.numeric(sssr2[,1]) newnew.y <- as.numeric(sssr2[,2]) print(points(as.numeric(newnew.x),-1*as.numeric(newnew.y),cex=1,pch=15,col=hex_codes1[19+1])) sssr1 <- names(ssr2[ssr2==21]) sssr2 <- NULL for (j in 1:length(sssr1)) { sssr3 <- strsplit(sssr1[j], "X")[[1]] sssr2 <- rbind(sssr2,as.numeric(sssr3)) } newnew.x <- as.numeric(sssr2[,1]) newnew.y <- as.numeric(sssr2[,2]) print(points(as.numeric(newnew.x),-1*as.numeric(newnew.y),cex=1,pch=15,col=hex_codes1[21+1])) dev.off() ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## # Focus FollowUp 20201116 ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## library(gplots) pbmc <- pbmc.Control.H250.185 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.Control.H250.185.dendrogram.tiff",width = 6, height = 8, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.Control.H250.185.heatmap.no.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.Control.H250.185.heatmap.with.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() pbmc <- pbmc.Control.H190.260 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.Control.H190.260.dendrogram.tiff",width = 6, height = 8, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.Control.H190.260.heatmap.no.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.Control.H190.260.heatmap.with.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() pbmc <- pbmc.Control.OFB57.194 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.Control.OFB57.194.dendrogram.tiff",width = 6, height = 8, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.Control.OFB57.194.heatmap.no.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.Control.OFB57.194.heatmap.with.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() pbmc <- pbmc.Control.OFB6A.107 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.Control.OFB6A.107.dendrogram.tiff",width = 6, height = 8, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.Control.OFB6A.107.heatmap.no.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.Control.OFB6A.107.heatmap.with.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() pbmc <- pbmc.AZ.109.146 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.AZ.109.146.dendrogram.tiff",width = 6, height = 8, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.AZ.109.146.heatmap.no.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.AZ.109.146.heatmap.with.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() pbmc <- pbmc.AZ.251.146 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.AZ.251.146.dendrogram.tiff",width = 6, height = 8, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.AZ.251.146.heatmap.no.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.AZ.251.146.heatmap.with.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() pbmc <- pbmc.AZ.84.145 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.AZ.84.145.dendrogram.tiff",width = 6, height = 8, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.AZ.84.145.heatmap.no.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.AZ.84.145.heatmap.with.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() pbmc <- pbmc.AZ.90.242 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.AZ.90.242.dendrogram.tiff",width = 6, height = 12, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.AZ.90.242.heatmap.no.zscore.tiff",width = 8, height = 12, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.AZ.90.242.heatmap.with.zscore.tiff",width = 8, height = 12, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() pbmc <- pbmc.AZ.99.140 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.AZ.99.140.dendrogram.tiff",width = 6, height = 8, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.AZ.99.140.heatmap.no.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.AZ.99.140.heatmap.with.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() pbmc <- pbmc.PD.52.247 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.PD.52.247.dendrogram.tiff",width = 6, height = 8, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.PD.52.247.heatmap.no.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.PD.52.247.heatmap.with.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() pbmc <- pbmc.PD.56.236 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.PD.56.236.dendrogram.tiff",width = 6, height = 8, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.PD.56.236.heatmap.no.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.PD.56.236.heatmap.with.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() pbmc <- pbmc.PD.58.229 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.PD.58.229.dendrogram.tiff",width = 6, height = 8, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.PD.58.229.heatmap.no.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.PD.58.229.heatmap.with.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() pbmc <- pbmc.PD.77.197 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.PD.77.197.dendrogram.tiff",width = 6, height = 8, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.PD.77.197.heatmap.no.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.PD.77.197.heatmap.with.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() pbmc <- pbmc.PD.79.201 # <----------------------------------------------------------------------------------------------------------------------------------HERE e <- ElbowPlot(pbmc, ndims=dim(pbmc$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.tree <- BuildClusterTree(pbmc,dims=1:dims2use) tttree <- Tool(object = pbmc.tree, slot = 'BuildClusterTree') tiff("pbmc.PD.79.201.dendrogram.tiff",width = 6, height = 8, units = "in", res=300) # <---------------------------------------------------------------------HERE print(plot(tttree)) dev.off() is_tip <- tttree$edge[,2] <= length(tttree$tip.label) ordered_tips <- tttree$edge[is_tip, 2] dend.order <- rev(tttree$tip.label[ordered_tips]) ppp <- AverageExpression(pbmc) final.ttt <- ppp[[2]] final.ttt <- final.ttt[,dend.order] final.ttt <- t(final.ttt) final.ttt <- ifelse(final.ttt<0,0,final.ttt) pal <- colorRampPalette(c("white", "red")) ccc <- pal(64) tiff("pbmc.PD.79.201.heatmap.no.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <--------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="none",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="No z-score",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() tiff("pbmc.PD.79.201.heatmap.with.zscore.tiff",width = 8, height = 8, units = "in", res=300) # <------------------------------------------------------------HERE print(hhhmap <- heatmap.2(final.ttt,Rowv=FALSE,Colv=TRUE,dendrogram="column",scale="row",col=ccc,trace="none",margins=c(10, 5),denscol="black",key.xlab="z-score (row)",key.ylab="Frequency",key.title="SCT",symbreaks=FALSE,symkey=FALSE)) dev.off() scp -vr *.tiff johnsonko@nindsdirbis7.ninds.nih.gov:/shares/PI/Kory_Johnson_and_Amar_Yavatkar/Alan_Koretsky/Helen_Murray/Spatial_Transcriptomics/20201006 ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## # SpatialDE Prep H250 - 20201029 ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## setwd("/data/johnsonko/SideProject/Helen/20200811/Analysis_Ready") library(stringr) load("Current_20201006.RData") pbmc.Control.H250.185 DimPlot(pbmc.Control.H250.185,reduction="umap",label=TRUE) ############################################################################ # Comparison A # Group 1 vs Groups 2, 3, 4, 5, 6, 7, 8 # Clusters 0, 1, 4, 14 vs clusters 2, 3, 6, 7, 11, 16, 13, 15, 9, 5, 8, 12 ############################################################################ temp <- as.character(unlist(pbmc.Control.H250.185$seurat_clusters)) temp <- ifelse(temp=="0","A",temp) temp <- ifelse(temp=="1","A",temp) temp <- ifelse(temp=="2","B",temp) temp <- ifelse(temp=="3","B",temp) temp <- ifelse(temp=="4","A",temp) temp <- ifelse(temp=="5","B",temp) temp <- ifelse(temp=="6","B",temp) temp <- ifelse(temp=="7","B",temp) temp <- ifelse(temp=="8","B",temp) temp <- ifelse(temp=="9","B",temp) temp <- ifelse(temp=="10","X",temp) temp <- ifelse(temp=="11","B",temp) temp <- ifelse(temp=="12","B",temp) temp <- ifelse(temp=="13","B",temp) temp <- ifelse(temp=="14","A",temp) temp <- ifelse(temp=="15","B",temp) temp <- ifelse(temp=="16","B",temp) temp <- ifelse(temp=="17","X",temp) temp <- ifelse(temp=="18","X",temp) temp <- ifelse(temp=="19","X",temp) temp <- ifelse(temp=="20","X",temp) temp <- ifelse(temp=="21","X",temp) temp <- ifelse(temp=="22","X",temp) temp <- ifelse(temp=="23","X",temp) temp <- ifelse(temp=="24","X",temp) temp <- ifelse(temp=="25","X",temp) pbmc.Control.H250.185@meta.data$comparisonA <- as.factor(temp) temp <- pbmc.Control.H250.185[,pbmc.Control.H250.185@meta.data$comparisonA!="X"] temp.data <- GetAssayData(temp, slot = "counts") temp.data <- as.matrix(temp.data) temp.data <- t(temp.data) temp <- dimnames(temp.data)[[1]] temp <- str_replace_all(temp,"X","x") dimnames(temp.data)[[1]] <- temp check.it <- apply(temp.data,1,max)>0 write.csv(temp.data,"comparisonA.csv") temp <- strsplit(temp,"x") temp <- as.data.frame(temp) temp <- t(temp) dimnames(temp)[[1]] <- dimnames(temp.data)[[1]] temp <- cbind(temp,apply(temp.data,1,sum)) dimnames(temp)[[2]] <- c("x","y","total_counts") write.csv(temp,"comparisonA.meta.csv") # SpatialDE # https://protect-au.mimecast.com/s/-zOOCWLVEjtX9E82fwl5tK?domain=github.com cd /data/johnsonko source /data/johnsonko/conda/etc/profile.d/conda.sh conda activate base conda activate project2 pip install openpyxl sinteractive --mem 500g --time 36:00:00 --gres=lscratch:500 python import matplotlib.pyplot as plt import pandas as pd import NaiveDE import SpatialDE counts = pd.read_csv('comparisonA.csv', index_col=0) sample_info = pd.read_csv('comparisonA.meta.csv', index_col=0) sample_info sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_a_round1.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_a_round2.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_a_round3.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_a_round4.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_a_round5.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_a_round6.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_a_round7.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_a_round8.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_a_round9.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_a_round10.xlsx') exit() conda deactivate conda deactivate # crunch library("openxlsx") library("xlsx") rnd1 <- read.xlsx("comparison_a_round1.xlsx","Sheet1",stringsAsFactors = T) rnd2 <- read.xlsx("comparison_a_round2.xlsx","Sheet1",stringsAsFactors = T) rnd3 <- read.xlsx("comparison_a_round3.xlsx","Sheet1",stringsAsFactors = T) rnd4 <- read.xlsx("comparison_a_round4.xlsx","Sheet1",stringsAsFactors = T) rnd5 <- read.xlsx("comparison_a_round5.xlsx","Sheet1",stringsAsFactors = T) rnd6 <- read.xlsx("comparison_a_round6.xlsx","Sheet1",stringsAsFactors = T) rnd7 <- read.xlsx("comparison_a_round7.xlsx","Sheet1",stringsAsFactors = T) rnd8 <- read.xlsx("comparison_a_round8.xlsx","Sheet1",stringsAsFactors = T) rnd9 <- read.xlsx("comparison_a_round9.xlsx","Sheet1",stringsAsFactors = T) rnd10 <- read.xlsx("comparison_a_round10.xlsx","Sheet1",stringsAsFactors = T) dimnames(rnd1)[[1]] <- rnd1$g dimnames(rnd2)[[1]] <- rnd2$g dimnames(rnd3)[[1]] <- rnd3$g dimnames(rnd4)[[1]] <- rnd4$g dimnames(rnd5)[[1]] <- rnd5$g dimnames(rnd6)[[1]] <- rnd6$g dimnames(rnd7)[[1]] <- rnd7$g dimnames(rnd8)[[1]] <- rnd8$g dimnames(rnd9)[[1]] <- rnd9$g dimnames(rnd10)[[1]] <- rnd10$g rnd2 <- rnd2[dimnames(rnd2)[[1]],] rnd3 <- rnd2[dimnames(rnd3)[[1]],] rnd4 <- rnd2[dimnames(rnd4)[[1]],] rnd5 <- rnd2[dimnames(rnd5)[[1]],] rnd6 <- rnd2[dimnames(rnd6)[[1]],] rnd7 <- rnd2[dimnames(rnd7)[[1]],] rnd8 <- rnd2[dimnames(rnd8)[[1]],] rnd9 <- rnd2[dimnames(rnd9)[[1]],] rnd10 <- rnd2[dimnames(rnd10)[[1]],] # https://protect-au.mimecast.com/s/WLeyCXLWGktD5QZ1fgxL4B?domain=stats.seandolinar.com rnd.cx <- cbind(rnd1$LLR,rnd2$LLR,rnd3$LLR,rnd4$LLR,rnd5$LLR,rnd6$LLR,rnd7$LLR,rnd8$LLR,rnd9$LLR,rnd10$LLR) dimnames(rnd.cx)[[1]] <- dimnames(rnd1)[[1]] rnd.cx.mean <- apply(rnd.cx,1,mean) rnd.cx.sd <- apply(rnd.cx,1,sd) rnd.cx.se <- https://protect-au.mimecast.com/s/T-okCYW8JlTp17XQcDWUHe?domain=rnd.cx.sd rnd.cx.z <- NULL rnd.cx.p <- NULL for (i in 1:length(rnd.cx.mean)) { rnd.temp1 <- (rnd.cx.mean[i]-mean(rnd.cx.mean[-c(i)]))/sd(rnd.cx.mean[-c(i)]) rnd.cx.z <- c(rnd.cx.z,rnd.temp1) rnd.temp1 <- 1-pnorm(rnd.temp1) rnd.cx.p <- c(rnd.cx.p,rnd.temp1) } rnd.cx.final <- cbind(rnd.cx.mean,rnd.cx.sd,rnd.cx.se,rnd.cx.z,rnd.cx.p) write.table(rnd.cx.final,"comparison_a_bootstrap_stats.txt",sep="\t") ############################################################################ # Comparison B # Group 2 vs Groups 1, 3, 4, 5, 6, 7, 8 # Cluster 2 vs clusters 0, 1, 4, 14, 3, 6, 7, 11, 16, 13, 15, 9, 5, 8, 12 ############################################################################ temp <- as.character(unlist(pbmc.Control.H250.185$seurat_clusters)) temp <- ifelse(temp=="0","B",temp) temp <- ifelse(temp=="1","B",temp) temp <- ifelse(temp=="2","A",temp) temp <- ifelse(temp=="3","B",temp) temp <- ifelse(temp=="4","B",temp) temp <- ifelse(temp=="5","B",temp) temp <- ifelse(temp=="6","B",temp) temp <- ifelse(temp=="7","B",temp) temp <- ifelse(temp=="8","B",temp) temp <- ifelse(temp=="9","B",temp) temp <- ifelse(temp=="10","X",temp) temp <- ifelse(temp=="11","B",temp) temp <- ifelse(temp=="12","B",temp) temp <- ifelse(temp=="13","B",temp) temp <- ifelse(temp=="14","B",temp) temp <- ifelse(temp=="15","B",temp) temp <- ifelse(temp=="16","B",temp) temp <- ifelse(temp=="17","X",temp) temp <- ifelse(temp=="18","X",temp) temp <- ifelse(temp=="19","X",temp) temp <- ifelse(temp=="20","X",temp) temp <- ifelse(temp=="21","X",temp) temp <- ifelse(temp=="22","X",temp) temp <- ifelse(temp=="23","X",temp) temp <- ifelse(temp=="24","X",temp) temp <- ifelse(temp=="25","X",temp) pbmc.Control.H250.185@meta.data$comparisonA <- as.factor(temp) temp <- pbmc.Control.H250.185[,pbmc.Control.H250.185@meta.data$comparisonA!="X"] temp.data <- GetAssayData(temp, slot = "counts") temp.data <- as.matrix(temp.data) temp.data <- t(temp.data) temp <- dimnames(temp.data)[[1]] temp <- str_replace_all(temp,"X","x") dimnames(temp.data)[[1]] <- temp write.csv(temp.data,"comparisonB.csv") temp <- strsplit(temp,"x") temp <- as.data.frame(temp) temp <- t(temp) dimnames(temp)[[1]] <- dimnames(temp.data)[[1]] temp <- cbind(temp,apply(temp.data,1,sum)) dimnames(temp)[[2]] <- c("x","y","total_counts") write.csv(temp,"comparisonB.meta.csv") # SpatialDE # https://protect-au.mimecast.com/s/-zOOCWLVEjtX9E82fwl5tK?domain=github.com cd /data/johnsonko source /data/johnsonko/conda/etc/profile.d/conda.sh conda activate base conda activate project2 pip install openpyxl sinteractive --mem 500g --time 36:00:00 --gres=lscratch:500 python import matplotlib.pyplot as plt import pandas as pd import NaiveDE import SpatialDE counts = pd.read_csv('comparisonB.csv', index_col=0) sample_info = pd.read_csv('comparisonB.meta.csv', index_col=0) sample_info sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_b_round1.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_b_round2.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_b_round3.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_b_round4.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_b_round5.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_b_round6.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_b_round7.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_b_round8.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_b_round9.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_b_round10.xlsx') exit() conda deactivate conda deactivate # crunch library("openxlsx") library("xlsx") rnd1 <- read.xlsx("comparison_b_round1.xlsx","Sheet1",stringsAsFactors = T) rnd2 <- read.xlsx("comparison_b_round2.xlsx","Sheet1",stringsAsFactors = T) rnd3 <- read.xlsx("comparison_b_round3.xlsx","Sheet1",stringsAsFactors = T) rnd4 <- read.xlsx("comparison_b_round4.xlsx","Sheet1",stringsAsFactors = T) rnd5 <- read.xlsx("comparison_b_round5.xlsx","Sheet1",stringsAsFactors = T) rnd6 <- read.xlsx("comparison_b_round6.xlsx","Sheet1",stringsAsFactors = T) rnd7 <- read.xlsx("comparison_b_round7.xlsx","Sheet1",stringsAsFactors = T) rnd8 <- read.xlsx("comparison_b_round8.xlsx","Sheet1",stringsAsFactors = T) rnd9 <- read.xlsx("comparison_b_round9.xlsx","Sheet1",stringsAsFactors = T) rnd10 <- read.xlsx("comparison_b_round10.xlsx","Sheet1",stringsAsFactors = T) dimnames(rnd1)[[1]] <- rnd1$g dimnames(rnd2)[[1]] <- rnd2$g dimnames(rnd3)[[1]] <- rnd3$g dimnames(rnd4)[[1]] <- rnd4$g dimnames(rnd5)[[1]] <- rnd5$g dimnames(rnd6)[[1]] <- rnd6$g dimnames(rnd7)[[1]] <- rnd7$g dimnames(rnd8)[[1]] <- rnd8$g dimnames(rnd9)[[1]] <- rnd9$g dimnames(rnd10)[[1]] <- rnd10$g rnd2 <- rnd2[dimnames(rnd2)[[1]],] rnd3 <- rnd2[dimnames(rnd3)[[1]],] rnd4 <- rnd2[dimnames(rnd4)[[1]],] rnd5 <- rnd2[dimnames(rnd5)[[1]],] rnd6 <- rnd2[dimnames(rnd6)[[1]],] rnd7 <- rnd2[dimnames(rnd7)[[1]],] rnd8 <- rnd2[dimnames(rnd8)[[1]],] rnd9 <- rnd2[dimnames(rnd9)[[1]],] rnd10 <- rnd2[dimnames(rnd10)[[1]],] rnd.cx <- cbind(rnd1$LLR,rnd2$LLR,rnd3$LLR,rnd4$LLR,rnd5$LLR,rnd6$LLR,rnd7$LLR,rnd8$LLR,rnd9$LLR,rnd10$LLR) dimnames(rnd.cx)[[1]] <- dimnames(rnd1)[[1]] rnd.cx.mean <- apply(rnd.cx,1,mean) rnd.cx.sd <- apply(rnd.cx,1,sd) rnd.cx.se <- https://protect-au.mimecast.com/s/T-okCYW8JlTp17XQcDWUHe?domain=rnd.cx.sd rnd.cx.z <- NULL rnd.cx.p <- NULL for (i in 1:length(rnd.cx.mean)) { rnd.temp1 <- (rnd.cx.mean[i]-mean(rnd.cx.mean[-c(i)]))/sd(rnd.cx.mean[-c(i)]) rnd.cx.z <- c(rnd.cx.z,rnd.temp1) rnd.temp1 <- 1-pnorm(rnd.temp1) rnd.cx.p <- c(rnd.cx.p,rnd.temp1) } rnd.cx.final <- cbind(rnd.cx.mean,rnd.cx.sd,rnd.cx.se,rnd.cx.z,rnd.cx.p) write.table(rnd.cx.final,"comparison_b_bootstrap_stats.txt",sep="\t") ############################################################################ # Comparison C # Group 3 vs Groups 1, 2, 4, 5, 6, 7, 8 # Cluster 3 vs clusters 0, 1, 4, 14, 2, 6, 7, 11, 16, 13, 15, 9, 5, 8, 12 ############################################################################ temp <- as.character(unlist(pbmc.Control.H250.185$seurat_clusters)) temp <- ifelse(temp=="0","B",temp) temp <- ifelse(temp=="1","B",temp) temp <- ifelse(temp=="2","B",temp) temp <- ifelse(temp=="3","A",temp) temp <- ifelse(temp=="4","B",temp) temp <- ifelse(temp=="5","B",temp) temp <- ifelse(temp=="6","B",temp) temp <- ifelse(temp=="7","B",temp) temp <- ifelse(temp=="8","B",temp) temp <- ifelse(temp=="9","B",temp) temp <- ifelse(temp=="10","X",temp) temp <- ifelse(temp=="11","B",temp) temp <- ifelse(temp=="12","B",temp) temp <- ifelse(temp=="13","B",temp) temp <- ifelse(temp=="14","B",temp) temp <- ifelse(temp=="15","B",temp) temp <- ifelse(temp=="16","B",temp) temp <- ifelse(temp=="17","X",temp) temp <- ifelse(temp=="18","X",temp) temp <- ifelse(temp=="19","X",temp) temp <- ifelse(temp=="20","X",temp) temp <- ifelse(temp=="21","X",temp) temp <- ifelse(temp=="22","X",temp) temp <- ifelse(temp=="23","X",temp) temp <- ifelse(temp=="24","X",temp) temp <- ifelse(temp=="25","X",temp) pbmc.Control.H250.185@meta.data$comparisonA <- as.factor(temp) temp <- pbmc.Control.H250.185[,pbmc.Control.H250.185@meta.data$comparisonA!="X"] temp.data <- GetAssayData(temp, slot = "counts") temp.data <- as.matrix(temp.data) temp.data <- t(temp.data) temp <- dimnames(temp.data)[[1]] temp <- str_replace_all(temp,"X","x") dimnames(temp.data)[[1]] <- temp write.csv(temp.data,"comparisonC.csv") temp <- strsplit(temp,"x") temp <- as.data.frame(temp) temp <- t(temp) dimnames(temp)[[1]] <- dimnames(temp.data)[[1]] temp <- cbind(temp,apply(temp.data,1,sum)) dimnames(temp)[[2]] <- c("x","y","total_counts") write.csv(temp,"comparisonC.meta.csv") # SpatialDE # https://protect-au.mimecast.com/s/-zOOCWLVEjtX9E82fwl5tK?domain=github.com cd /data/johnsonko source /data/johnsonko/conda/etc/profile.d/conda.sh conda activate base conda activate project2 pip install openpyxl sinteractive --mem 500g --time 36:00:00 --gres=lscratch:500 python import matplotlib.pyplot as plt import pandas as pd import NaiveDE import SpatialDE counts = pd.read_csv('comparisonC.csv', index_col=0) sample_info = pd.read_csv('comparisonC.meta.csv', index_col=0) sample_info sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_c_round1.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_c_round2.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_c_round3.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_c_round4.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_c_round5.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_c_round6.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_c_round7.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_c_round8.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_c_round9.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_c_round10.xlsx') exit() conda deactivate conda deactivate # crunch library("openxlsx") library("xlsx") rnd1 <- read.xlsx("comparison_c_round1.xlsx","Sheet1",stringsAsFactors = T) rnd2 <- read.xlsx("comparison_c_round2.xlsx","Sheet1",stringsAsFactors = T) rnd3 <- read.xlsx("comparison_c_round3.xlsx","Sheet1",stringsAsFactors = T) rnd4 <- read.xlsx("comparison_c_round4.xlsx","Sheet1",stringsAsFactors = T) rnd5 <- read.xlsx("comparison_c_round5.xlsx","Sheet1",stringsAsFactors = T) rnd6 <- read.xlsx("comparison_c_round6.xlsx","Sheet1",stringsAsFactors = T) rnd7 <- read.xlsx("comparison_c_round7.xlsx","Sheet1",stringsAsFactors = T) rnd8 <- read.xlsx("comparison_c_round8.xlsx","Sheet1",stringsAsFactors = T) rnd9 <- read.xlsx("comparison_c_round9.xlsx","Sheet1",stringsAsFactors = T) rnd10 <- read.xlsx("comparison_c_round10.xlsx","Sheet1",stringsAsFactors = T) dimnames(rnd1)[[1]] <- rnd1$g dimnames(rnd2)[[1]] <- rnd2$g dimnames(rnd3)[[1]] <- rnd3$g dimnames(rnd4)[[1]] <- rnd4$g dimnames(rnd5)[[1]] <- rnd5$g dimnames(rnd6)[[1]] <- rnd6$g dimnames(rnd7)[[1]] <- rnd7$g dimnames(rnd8)[[1]] <- rnd8$g dimnames(rnd9)[[1]] <- rnd9$g dimnames(rnd10)[[1]] <- rnd10$g rnd2 <- rnd2[dimnames(rnd2)[[1]],] rnd3 <- rnd2[dimnames(rnd3)[[1]],] rnd4 <- rnd2[dimnames(rnd4)[[1]],] rnd5 <- rnd2[dimnames(rnd5)[[1]],] rnd6 <- rnd2[dimnames(rnd6)[[1]],] rnd7 <- rnd2[dimnames(rnd7)[[1]],] rnd8 <- rnd2[dimnames(rnd8)[[1]],] rnd9 <- rnd2[dimnames(rnd9)[[1]],] rnd10 <- rnd2[dimnames(rnd10)[[1]],] rnd.cx <- cbind(rnd1$LLR,rnd2$LLR,rnd3$LLR,rnd4$LLR,rnd5$LLR,rnd6$LLR,rnd7$LLR,rnd8$LLR,rnd9$LLR,rnd10$LLR) dimnames(rnd.cx)[[1]] <- dimnames(rnd1)[[1]] rnd.cx.mean <- apply(rnd.cx,1,mean) rnd.cx.sd <- apply(rnd.cx,1,sd) rnd.cx.se <- https://protect-au.mimecast.com/s/T-okCYW8JlTp17XQcDWUHe?domain=rnd.cx.sd rnd.cx.z <- NULL rnd.cx.p <- NULL for (i in 1:length(rnd.cx.mean)) { rnd.temp1 <- (rnd.cx.mean[i]-mean(rnd.cx.mean[-c(i)]))/sd(rnd.cx.mean[-c(i)]) rnd.cx.z <- c(rnd.cx.z,rnd.temp1) rnd.temp1 <- 1-pnorm(rnd.temp1) rnd.cx.p <- c(rnd.cx.p,rnd.temp1) } rnd.cx.final <- cbind(rnd.cx.mean,rnd.cx.sd,rnd.cx.se,rnd.cx.z,rnd.cx.p) write.table(rnd.cx.final,"comparison_c_bootstrap_stats.txt",sep="\t") ############################################################################ # Comparison D # Group 4 vs Groups 1, 2, 3, 5, 6, 7, 8 # Cluster 6, 7, 11 vs clusters 0, 1, 4, 14, 2, 3, 16, 13, 15, 9, 5, 8, 12 ############################################################################ temp <- as.character(unlist(pbmc.Control.H250.185$seurat_clusters)) temp <- ifelse(temp=="0","B",temp) temp <- ifelse(temp=="1","B",temp) temp <- ifelse(temp=="2","B",temp) temp <- ifelse(temp=="3","B",temp) temp <- ifelse(temp=="4","B",temp) temp <- ifelse(temp=="5","B",temp) temp <- ifelse(temp=="6","A",temp) temp <- ifelse(temp=="7","A",temp) temp <- ifelse(temp=="8","B",temp) temp <- ifelse(temp=="9","B",temp) temp <- ifelse(temp=="10","X",temp) temp <- ifelse(temp=="11","A",temp) temp <- ifelse(temp=="12","B",temp) temp <- ifelse(temp=="13","B",temp) temp <- ifelse(temp=="14","B",temp) temp <- ifelse(temp=="15","B",temp) temp <- ifelse(temp=="16","B",temp) temp <- ifelse(temp=="17","X",temp) temp <- ifelse(temp=="18","X",temp) temp <- ifelse(temp=="19","X",temp) temp <- ifelse(temp=="20","X",temp) temp <- ifelse(temp=="21","X",temp) temp <- ifelse(temp=="22","X",temp) temp <- ifelse(temp=="23","X",temp) temp <- ifelse(temp=="24","X",temp) temp <- ifelse(temp=="25","X",temp) pbmc.Control.H250.185@meta.data$comparisonA <- as.factor(temp) temp <- pbmc.Control.H250.185[,pbmc.Control.H250.185@meta.data$comparisonA!="X"] temp.data <- GetAssayData(temp, slot = "counts") temp.data <- as.matrix(temp.data) temp.data <- t(temp.data) temp <- dimnames(temp.data)[[1]] temp <- str_replace_all(temp,"X","x") dimnames(temp.data)[[1]] <- temp write.csv(temp.data,"comparisonD.csv") temp <- strsplit(temp,"x") temp <- as.data.frame(temp) temp <- t(temp) dimnames(temp)[[1]] <- dimnames(temp.data)[[1]] temp <- cbind(temp,apply(temp.data,1,sum)) dimnames(temp)[[2]] <- c("x","y","total_counts") write.csv(temp,"comparisonD.meta.csv") # SpatialDE # https://protect-au.mimecast.com/s/-zOOCWLVEjtX9E82fwl5tK?domain=github.com cd /data/johnsonko source /data/johnsonko/conda/etc/profile.d/conda.sh conda activate base conda activate project2 pip install openpyxl sinteractive --mem 500g --time 36:00:00 --gres=lscratch:500 python import matplotlib.pyplot as plt import pandas as pd import NaiveDE import SpatialDE counts = pd.read_csv('comparisonD.csv', index_col=0) sample_info = pd.read_csv('comparisonD.meta.csv', index_col=0) sample_info sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_d_round1.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_d_round2.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_d_round3.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_d_round4.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_d_round5.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_d_round6.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_d_round7.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_d_round8.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_d_round9.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_d_round10.xlsx') exit() conda deactivate conda deactivate # crunch library("openxlsx") library("xlsx") rnd1 <- read.xlsx("comparison_d_round1.xlsx","Sheet1",stringsAsFactors = T) rnd2 <- read.xlsx("comparison_d_round2.xlsx","Sheet1",stringsAsFactors = T) rnd3 <- read.xlsx("comparison_d_round3.xlsx","Sheet1",stringsAsFactors = T) rnd4 <- read.xlsx("comparison_d_round4.xlsx","Sheet1",stringsAsFactors = T) rnd5 <- read.xlsx("comparison_d_round5.xlsx","Sheet1",stringsAsFactors = T) rnd6 <- read.xlsx("comparison_d_round6.xlsx","Sheet1",stringsAsFactors = T) rnd7 <- read.xlsx("comparison_d_round7.xlsx","Sheet1",stringsAsFactors = T) rnd8 <- read.xlsx("comparison_d_round8.xlsx","Sheet1",stringsAsFactors = T) rnd9 <- read.xlsx("comparison_d_round9.xlsx","Sheet1",stringsAsFactors = T) rnd10 <- read.xlsx("comparison_d_round10.xlsx","Sheet1",stringsAsFactors = T) dimnames(rnd1)[[1]] <- rnd1$g dimnames(rnd2)[[1]] <- rnd2$g dimnames(rnd3)[[1]] <- rnd3$g dimnames(rnd4)[[1]] <- rnd4$g dimnames(rnd5)[[1]] <- rnd5$g dimnames(rnd6)[[1]] <- rnd6$g dimnames(rnd7)[[1]] <- rnd7$g dimnames(rnd8)[[1]] <- rnd8$g dimnames(rnd9)[[1]] <- rnd9$g dimnames(rnd10)[[1]] <- rnd10$g rnd2 <- rnd2[dimnames(rnd2)[[1]],] rnd3 <- rnd2[dimnames(rnd3)[[1]],] rnd4 <- rnd2[dimnames(rnd4)[[1]],] rnd5 <- rnd2[dimnames(rnd5)[[1]],] rnd6 <- rnd2[dimnames(rnd6)[[1]],] rnd7 <- rnd2[dimnames(rnd7)[[1]],] rnd8 <- rnd2[dimnames(rnd8)[[1]],] rnd9 <- rnd2[dimnames(rnd9)[[1]],] rnd10 <- rnd2[dimnames(rnd10)[[1]],] rnd.cx <- cbind(rnd1$LLR,rnd2$LLR,rnd3$LLR,rnd4$LLR,rnd5$LLR,rnd6$LLR,rnd7$LLR,rnd8$LLR,rnd9$LLR,rnd10$LLR) dimnames(rnd.cx)[[1]] <- dimnames(rnd1)[[1]] rnd.cx.mean <- apply(rnd.cx,1,mean) rnd.cx.sd <- apply(rnd.cx,1,sd) rnd.cx.se <- https://protect-au.mimecast.com/s/T-okCYW8JlTp17XQcDWUHe?domain=rnd.cx.sd rnd.cx.z <- NULL rnd.cx.p <- NULL for (i in 1:length(rnd.cx.mean)) { rnd.temp1 <- (rnd.cx.mean[i]-mean(rnd.cx.mean[-c(i)]))/sd(rnd.cx.mean[-c(i)]) rnd.cx.z <- c(rnd.cx.z,rnd.temp1) rnd.temp1 <- 1-pnorm(rnd.temp1) rnd.cx.p <- c(rnd.cx.p,rnd.temp1) } rnd.cx.final <- cbind(rnd.cx.mean,rnd.cx.sd,rnd.cx.se,rnd.cx.z,rnd.cx.p) write.table(rnd.cx.final,"comparison_d_bootstrap_stats.txt",sep="\t") ############################################################################ # Comparison E # Group 5 vs Groups 1, 2, 3, 4, 6, 7, 8 # Cluster 16 vs clusters 0, 1, 4, 14, 2, 3, 6, 7, 11, 13, 15, 9, 5, 8, 12 ############################################################################ temp <- as.character(unlist(pbmc.Control.H250.185$seurat_clusters)) temp <- ifelse(temp=="0","B",temp) temp <- ifelse(temp=="1","B",temp) temp <- ifelse(temp=="2","B",temp) temp <- ifelse(temp=="3","B",temp) temp <- ifelse(temp=="4","B",temp) temp <- ifelse(temp=="5","B",temp) temp <- ifelse(temp=="6","B",temp) temp <- ifelse(temp=="7","B",temp) temp <- ifelse(temp=="8","B",temp) temp <- ifelse(temp=="9","B",temp) temp <- ifelse(temp=="10","X",temp) temp <- ifelse(temp=="11","B",temp) temp <- ifelse(temp=="12","B",temp) temp <- ifelse(temp=="13","B",temp) temp <- ifelse(temp=="14","B",temp) temp <- ifelse(temp=="15","B",temp) temp <- ifelse(temp=="16","A",temp) temp <- ifelse(temp=="17","X",temp) temp <- ifelse(temp=="18","X",temp) temp <- ifelse(temp=="19","X",temp) temp <- ifelse(temp=="20","X",temp) temp <- ifelse(temp=="21","X",temp) temp <- ifelse(temp=="22","X",temp) temp <- ifelse(temp=="23","X",temp) temp <- ifelse(temp=="24","X",temp) temp <- ifelse(temp=="25","X",temp) pbmc.Control.H250.185@meta.data$comparisonA <- as.factor(temp) temp <- pbmc.Control.H250.185[,pbmc.Control.H250.185@meta.data$comparisonA!="X"] temp.data <- GetAssayData(temp, slot = "counts") temp.data <- as.matrix(temp.data) temp.data <- t(temp.data) temp <- dimnames(temp.data)[[1]] temp <- str_replace_all(temp,"X","x") dimnames(temp.data)[[1]] <- temp write.csv(temp.data,"comparisonE.csv") temp <- strsplit(temp,"x") temp <- as.data.frame(temp) temp <- t(temp) dimnames(temp)[[1]] <- dimnames(temp.data)[[1]] temp <- cbind(temp,apply(temp.data,1,sum)) dimnames(temp)[[2]] <- c("x","y","total_counts") write.csv(temp,"comparisonE.meta.csv") # SpatialDE # https://protect-au.mimecast.com/s/-zOOCWLVEjtX9E82fwl5tK?domain=github.com cd /data/johnsonko source /data/johnsonko/conda/etc/profile.d/conda.sh conda activate base conda activate project2 pip install openpyxl sinteractive --mem 500g --time 36:00:00 --gres=lscratch:500 python import matplotlib.pyplot as plt import pandas as pd import NaiveDE import SpatialDE counts = pd.read_csv('comparisonE.csv', index_col=0) sample_info = pd.read_csv('comparisonE.meta.csv', index_col=0) sample_info sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_e_round1.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_e_round2.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_e_round3.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_e_round4.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_e_round5.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_e_round6.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_e_round7.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_e_round8.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_e_round9.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_e_round10.xlsx') exit() conda deactivate conda deactivate # crunch library("openxlsx") library("xlsx") rnd1 <- read.xlsx("comparison_e_round1.xlsx","Sheet1",stringsAsFactors = T) rnd2 <- read.xlsx("comparison_e_round2.xlsx","Sheet1",stringsAsFactors = T) rnd3 <- read.xlsx("comparison_e_round3.xlsx","Sheet1",stringsAsFactors = T) rnd4 <- read.xlsx("comparison_e_round4.xlsx","Sheet1",stringsAsFactors = T) rnd5 <- read.xlsx("comparison_e_round5.xlsx","Sheet1",stringsAsFactors = T) rnd6 <- read.xlsx("comparison_e_round6.xlsx","Sheet1",stringsAsFactors = T) rnd7 <- read.xlsx("comparison_e_round7.xlsx","Sheet1",stringsAsFactors = T) rnd8 <- read.xlsx("comparison_e_round8.xlsx","Sheet1",stringsAsFactors = T) rnd9 <- read.xlsx("comparison_e_round9.xlsx","Sheet1",stringsAsFactors = T) rnd10 <- read.xlsx("comparison_e_round10.xlsx","Sheet1",stringsAsFactors = T) dimnames(rnd1)[[1]] <- rnd1$g dimnames(rnd2)[[1]] <- rnd2$g dimnames(rnd3)[[1]] <- rnd3$g dimnames(rnd4)[[1]] <- rnd4$g dimnames(rnd5)[[1]] <- rnd5$g dimnames(rnd6)[[1]] <- rnd6$g dimnames(rnd7)[[1]] <- rnd7$g dimnames(rnd8)[[1]] <- rnd8$g dimnames(rnd9)[[1]] <- rnd9$g dimnames(rnd10)[[1]] <- rnd10$g rnd2 <- rnd2[dimnames(rnd2)[[1]],] rnd3 <- rnd2[dimnames(rnd3)[[1]],] rnd4 <- rnd2[dimnames(rnd4)[[1]],] rnd5 <- rnd2[dimnames(rnd5)[[1]],] rnd6 <- rnd2[dimnames(rnd6)[[1]],] rnd7 <- rnd2[dimnames(rnd7)[[1]],] rnd8 <- rnd2[dimnames(rnd8)[[1]],] rnd9 <- rnd2[dimnames(rnd9)[[1]],] rnd10 <- rnd2[dimnames(rnd10)[[1]],] rnd.cx <- cbind(rnd1$LLR,rnd2$LLR,rnd3$LLR,rnd4$LLR,rnd5$LLR,rnd6$LLR,rnd7$LLR,rnd8$LLR,rnd9$LLR,rnd10$LLR) dimnames(rnd.cx)[[1]] <- dimnames(rnd1)[[1]] rnd.cx.mean <- apply(rnd.cx,1,mean) rnd.cx.sd <- apply(rnd.cx,1,sd) rnd.cx.se <- https://protect-au.mimecast.com/s/T-okCYW8JlTp17XQcDWUHe?domain=rnd.cx.sd rnd.cx.z <- NULL rnd.cx.p <- NULL for (i in 1:length(rnd.cx.mean)) { rnd.temp1 <- (rnd.cx.mean[i]-mean(rnd.cx.mean[-c(i)]))/sd(rnd.cx.mean[-c(i)]) rnd.cx.z <- c(rnd.cx.z,rnd.temp1) rnd.temp1 <- 1-pnorm(rnd.temp1) rnd.cx.p <- c(rnd.cx.p,rnd.temp1) } rnd.cx.final <- cbind(rnd.cx.mean,rnd.cx.sd,rnd.cx.se,rnd.cx.z,rnd.cx.p) write.table(rnd.cx.final,"comparison_e_bootstrap_stats.txt",sep="\t") ############################################################################ # Comparison F # Group 6 vs Groups 1, 2, 3, 4, 5, 7, 8 # Cluster 13, 15 vs clusters 0, 1, 4, 14, 2, 3, 6, 7, 11, 16, 9, 5, 8, 12 ############################################################################ temp <- as.character(unlist(pbmc.Control.H250.185$seurat_clusters)) temp <- ifelse(temp=="0","B",temp) temp <- ifelse(temp=="1","B",temp) temp <- ifelse(temp=="2","B",temp) temp <- ifelse(temp=="3","B",temp) temp <- ifelse(temp=="4","B",temp) temp <- ifelse(temp=="5","B",temp) temp <- ifelse(temp=="6","B",temp) temp <- ifelse(temp=="7","B",temp) temp <- ifelse(temp=="8","B",temp) temp <- ifelse(temp=="9","B",temp) temp <- ifelse(temp=="10","X",temp) temp <- ifelse(temp=="11","B",temp) temp <- ifelse(temp=="12","B",temp) temp <- ifelse(temp=="13","A",temp) temp <- ifelse(temp=="14","B",temp) temp <- ifelse(temp=="15","A",temp) temp <- ifelse(temp=="16","B",temp) temp <- ifelse(temp=="17","X",temp) temp <- ifelse(temp=="18","X",temp) temp <- ifelse(temp=="19","X",temp) temp <- ifelse(temp=="20","X",temp) temp <- ifelse(temp=="21","X",temp) temp <- ifelse(temp=="22","X",temp) temp <- ifelse(temp=="23","X",temp) temp <- ifelse(temp=="24","X",temp) temp <- ifelse(temp=="25","X",temp) pbmc.Control.H250.185@meta.data$comparisonA <- as.factor(temp) temp <- pbmc.Control.H250.185[,pbmc.Control.H250.185@meta.data$comparisonA!="X"] temp.data <- GetAssayData(temp, slot = "counts") temp.data <- as.matrix(temp.data) temp.data <- t(temp.data) temp <- dimnames(temp.data)[[1]] temp <- str_replace_all(temp,"X","x") dimnames(temp.data)[[1]] <- temp write.csv(temp.data,"comparisonF.csv") temp <- strsplit(temp,"x") temp <- as.data.frame(temp) temp <- t(temp) dimnames(temp)[[1]] <- dimnames(temp.data)[[1]] temp <- cbind(temp,apply(temp.data,1,sum)) dimnames(temp)[[2]] <- c("x","y","total_counts") write.csv(temp,"comparisonF.meta.csv") # SpatialDE # https://protect-au.mimecast.com/s/-zOOCWLVEjtX9E82fwl5tK?domain=github.com cd /data/johnsonko source /data/johnsonko/conda/etc/profile.d/conda.sh conda activate base conda activate project2 pip install openpyxl sinteractive --mem 500g --time 36:00:00 --gres=lscratch:500 python import matplotlib.pyplot as plt import pandas as pd import NaiveDE import SpatialDE counts = pd.read_csv('comparisonF.csv', index_col=0) sample_info = pd.read_csv('comparisonF.meta.csv', index_col=0) sample_info sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_f_round1.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_f_round2.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_f_round3.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_f_round4.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_f_round5.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_f_round6.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_f_round7.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_f_round8.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_f_round9.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_f_round10.xlsx') exit() conda deactivate conda deactivate # crunch library("openxlsx") library("xlsx") rnd1 <- read.xlsx("comparison_f_round1.xlsx","Sheet1",stringsAsFactors = T) rnd2 <- read.xlsx("comparison_f_round2.xlsx","Sheet1",stringsAsFactors = T) rnd3 <- read.xlsx("comparison_f_round3.xlsx","Sheet1",stringsAsFactors = T) rnd4 <- read.xlsx("comparison_f_round4.xlsx","Sheet1",stringsAsFactors = T) rnd5 <- read.xlsx("comparison_f_round5.xlsx","Sheet1",stringsAsFactors = T) rnd6 <- read.xlsx("comparison_f_round6.xlsx","Sheet1",stringsAsFactors = T) rnd7 <- read.xlsx("comparison_f_round7.xlsx","Sheet1",stringsAsFactors = T) rnd8 <- read.xlsx("comparison_f_round8.xlsx","Sheet1",stringsAsFactors = T) rnd9 <- read.xlsx("comparison_f_round9.xlsx","Sheet1",stringsAsFactors = T) rnd10 <- read.xlsx("comparison_f_round10.xlsx","Sheet1",stringsAsFactors = T) dimnames(rnd1)[[1]] <- rnd1$g dimnames(rnd2)[[1]] <- rnd2$g dimnames(rnd3)[[1]] <- rnd3$g dimnames(rnd4)[[1]] <- rnd4$g dimnames(rnd5)[[1]] <- rnd5$g dimnames(rnd6)[[1]] <- rnd6$g dimnames(rnd7)[[1]] <- rnd7$g dimnames(rnd8)[[1]] <- rnd8$g dimnames(rnd9)[[1]] <- rnd9$g dimnames(rnd10)[[1]] <- rnd10$g rnd2 <- rnd2[dimnames(rnd2)[[1]],] rnd3 <- rnd2[dimnames(rnd3)[[1]],] rnd4 <- rnd2[dimnames(rnd4)[[1]],] rnd5 <- rnd2[dimnames(rnd5)[[1]],] rnd6 <- rnd2[dimnames(rnd6)[[1]],] rnd7 <- rnd2[dimnames(rnd7)[[1]],] rnd8 <- rnd2[dimnames(rnd8)[[1]],] rnd9 <- rnd2[dimnames(rnd9)[[1]],] rnd10 <- rnd2[dimnames(rnd10)[[1]],] rnd.cx <- cbind(rnd1$LLR,rnd2$LLR,rnd3$LLR,rnd4$LLR,rnd5$LLR,rnd6$LLR,rnd7$LLR,rnd8$LLR,rnd9$LLR,rnd10$LLR) dimnames(rnd.cx)[[1]] <- dimnames(rnd1)[[1]] rnd.cx.mean <- apply(rnd.cx,1,mean) rnd.cx.sd <- apply(rnd.cx,1,sd) rnd.cx.se <- https://protect-au.mimecast.com/s/T-okCYW8JlTp17XQcDWUHe?domain=rnd.cx.sd rnd.cx.z <- NULL rnd.cx.p <- NULL for (i in 1:length(rnd.cx.mean)) { rnd.temp1 <- (rnd.cx.mean[i]-mean(rnd.cx.mean[-c(i)]))/sd(rnd.cx.mean[-c(i)]) rnd.cx.z <- c(rnd.cx.z,rnd.temp1) rnd.temp1 <- 1-pnorm(rnd.temp1) rnd.cx.p <- c(rnd.cx.p,rnd.temp1) } rnd.cx.final <- cbind(rnd.cx.mean,rnd.cx.sd,rnd.cx.se,rnd.cx.z,rnd.cx.p) write.table(rnd.cx.final,"comparison_f_bootstrap_stats.txt",sep="\t") ############################################################################ # Comparison G # Group 7 vs Groups 1, 2, 3, 4, 5, 6, 8 # Cluster 9 vs clusters 0, 1, 4, 14, 2, 3, 6, 7, 11, 13, 15, 16, 5, 8, 12 ############################################################################ temp <- as.character(unlist(pbmc.Control.H250.185$seurat_clusters)) temp <- ifelse(temp=="0","B",temp) temp <- ifelse(temp=="1","B",temp) temp <- ifelse(temp=="2","B",temp) temp <- ifelse(temp=="3","B",temp) temp <- ifelse(temp=="4","B",temp) temp <- ifelse(temp=="5","B",temp) temp <- ifelse(temp=="6","B",temp) temp <- ifelse(temp=="7","B",temp) temp <- ifelse(temp=="8","B",temp) temp <- ifelse(temp=="9","A",temp) temp <- ifelse(temp=="10","X",temp) temp <- ifelse(temp=="11","B",temp) temp <- ifelse(temp=="12","B",temp) temp <- ifelse(temp=="13","B",temp) temp <- ifelse(temp=="14","B",temp) temp <- ifelse(temp=="15","B",temp) temp <- ifelse(temp=="16","B",temp) temp <- ifelse(temp=="17","X",temp) temp <- ifelse(temp=="18","X",temp) temp <- ifelse(temp=="19","X",temp) temp <- ifelse(temp=="20","X",temp) temp <- ifelse(temp=="21","X",temp) temp <- ifelse(temp=="22","X",temp) temp <- ifelse(temp=="23","X",temp) temp <- ifelse(temp=="24","X",temp) temp <- ifelse(temp=="25","X",temp) pbmc.Control.H250.185@meta.data$comparisonA <- as.factor(temp) temp <- pbmc.Control.H250.185[,pbmc.Control.H250.185@meta.data$comparisonA!="X"] temp.data <- GetAssayData(temp, slot = "counts") temp.data <- as.matrix(temp.data) temp.data <- t(temp.data) temp <- dimnames(temp.data)[[1]] temp <- str_replace_all(temp,"X","x") dimnames(temp.data)[[1]] <- temp write.csv(temp.data,"comparisonG.csv") temp <- strsplit(temp,"x") temp <- as.data.frame(temp) temp <- t(temp) dimnames(temp)[[1]] <- dimnames(temp.data)[[1]] temp <- cbind(temp,apply(temp.data,1,sum)) dimnames(temp)[[2]] <- c("x","y","total_counts") write.csv(temp,"comparisonG.meta.csv") # SpatialDE # https://protect-au.mimecast.com/s/-zOOCWLVEjtX9E82fwl5tK?domain=github.com cd /data/johnsonko source /data/johnsonko/conda/etc/profile.d/conda.sh conda activate base conda activate project2 pip install openpyxl sinteractive --mem 500g --time 36:00:00 --gres=lscratch:500 python import matplotlib.pyplot as plt import pandas as pd import NaiveDE import SpatialDE counts = pd.read_csv('comparisonG.csv', index_col=0) sample_info = pd.read_csv('comparisonG.meta.csv', index_col=0) sample_info sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_g_round1.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_g_round2.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_g_round3.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_g_round4.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_g_round5.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_g_round6.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_g_round7.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_g_round8.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_g_round9.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_g_round10.xlsx') exit() conda deactivate conda deactivate # crunch library("openxlsx") library("xlsx") rnd1 <- read.xlsx("comparison_g_round1.xlsx","Sheet1",stringsAsFactors = T) rnd2 <- read.xlsx("comparison_g_round2.xlsx","Sheet1",stringsAsFactors = T) rnd3 <- read.xlsx("comparison_g_round3.xlsx","Sheet1",stringsAsFactors = T) rnd4 <- read.xlsx("comparison_g_round4.xlsx","Sheet1",stringsAsFactors = T) rnd5 <- read.xlsx("comparison_g_round5.xlsx","Sheet1",stringsAsFactors = T) rnd6 <- read.xlsx("comparison_g_round6.xlsx","Sheet1",stringsAsFactors = T) rnd7 <- read.xlsx("comparison_g_round7.xlsx","Sheet1",stringsAsFactors = T) rnd8 <- read.xlsx("comparison_g_round8.xlsx","Sheet1",stringsAsFactors = T) rnd9 <- read.xlsx("comparison_g_round9.xlsx","Sheet1",stringsAsFactors = T) rnd10 <- read.xlsx("comparison_g_round10.xlsx","Sheet1",stringsAsFactors = T) dimnames(rnd1)[[1]] <- rnd1$g dimnames(rnd2)[[1]] <- rnd2$g dimnames(rnd3)[[1]] <- rnd3$g dimnames(rnd4)[[1]] <- rnd4$g dimnames(rnd5)[[1]] <- rnd5$g dimnames(rnd6)[[1]] <- rnd6$g dimnames(rnd7)[[1]] <- rnd7$g dimnames(rnd8)[[1]] <- rnd8$g dimnames(rnd9)[[1]] <- rnd9$g dimnames(rnd10)[[1]] <- rnd10$g rnd2 <- rnd2[dimnames(rnd2)[[1]],] rnd3 <- rnd2[dimnames(rnd3)[[1]],] rnd4 <- rnd2[dimnames(rnd4)[[1]],] rnd5 <- rnd2[dimnames(rnd5)[[1]],] rnd6 <- rnd2[dimnames(rnd6)[[1]],] rnd7 <- rnd2[dimnames(rnd7)[[1]],] rnd8 <- rnd2[dimnames(rnd8)[[1]],] rnd9 <- rnd2[dimnames(rnd9)[[1]],] rnd10 <- rnd2[dimnames(rnd10)[[1]],] rnd.cx <- cbind(rnd1$LLR,rnd2$LLR,rnd3$LLR,rnd4$LLR,rnd5$LLR,rnd6$LLR,rnd7$LLR,rnd8$LLR,rnd9$LLR,rnd10$LLR) dimnames(rnd.cx)[[1]] <- dimnames(rnd1)[[1]] rnd.cx.mean <- apply(rnd.cx,1,mean) rnd.cx.sd <- apply(rnd.cx,1,sd) rnd.cx.se <- https://protect-au.mimecast.com/s/T-okCYW8JlTp17XQcDWUHe?domain=rnd.cx.sd rnd.cx.z <- NULL rnd.cx.p <- NULL for (i in 1:length(rnd.cx.mean)) { rnd.temp1 <- (rnd.cx.mean[i]-mean(rnd.cx.mean[-c(i)]))/sd(rnd.cx.mean[-c(i)]) rnd.cx.z <- c(rnd.cx.z,rnd.temp1) rnd.temp1 <- 1-pnorm(rnd.temp1) rnd.cx.p <- c(rnd.cx.p,rnd.temp1) } rnd.cx.final <- cbind(rnd.cx.mean,rnd.cx.sd,rnd.cx.se,rnd.cx.z,rnd.cx.p) write.table(rnd.cx.final,"comparison_g_bootstrap_stats.txt",sep="\t") ############################################################################ # Comparison H # Group 8 vs Groups 1, 2, 3, 4, 5, 6, 7 # Cluster 5 vs clusters 0, 1, 4, 14, 2, 3, 6, 7, 11, 13, 15, 9, 16 ############################################################################ temp <- as.character(unlist(pbmc.Control.H250.185$seurat_clusters)) temp <- ifelse(temp=="0","B",temp) temp <- ifelse(temp=="1","B",temp) temp <- ifelse(temp=="2","B",temp) temp <- ifelse(temp=="3","B",temp) temp <- ifelse(temp=="4","B",temp) temp <- ifelse(temp=="5","A",temp) temp <- ifelse(temp=="6","B",temp) temp <- ifelse(temp=="7","B",temp) temp <- ifelse(temp=="8","X",temp) temp <- ifelse(temp=="9","B",temp) temp <- ifelse(temp=="10","X",temp) temp <- ifelse(temp=="11","B",temp) temp <- ifelse(temp=="12","X",temp) temp <- ifelse(temp=="13","B",temp) temp <- ifelse(temp=="14","B",temp) temp <- ifelse(temp=="15","B",temp) temp <- ifelse(temp=="16","B",temp) temp <- ifelse(temp=="17","X",temp) temp <- ifelse(temp=="18","X",temp) temp <- ifelse(temp=="19","X",temp) temp <- ifelse(temp=="20","X",temp) temp <- ifelse(temp=="21","X",temp) temp <- ifelse(temp=="22","X",temp) temp <- ifelse(temp=="23","X",temp) temp <- ifelse(temp=="24","X",temp) temp <- ifelse(temp=="25","X",temp) pbmc.Control.H250.185@meta.data$comparisonA <- as.factor(temp) temp <- pbmc.Control.H250.185[,pbmc.Control.H250.185@meta.data$comparisonA!="X"] temp.data <- GetAssayData(temp, slot = "counts") temp.data <- as.matrix(temp.data) temp.data <- t(temp.data) temp <- dimnames(temp.data)[[1]] temp <- str_replace_all(temp,"X","x") dimnames(temp.data)[[1]] <- temp write.csv(temp.data,"comparisonH.csv") temp <- strsplit(temp,"x") temp <- as.data.frame(temp) temp <- t(temp) dimnames(temp)[[1]] <- dimnames(temp.data)[[1]] temp <- cbind(temp,apply(temp.data,1,sum)) dimnames(temp)[[2]] <- c("x","y","total_counts") write.csv(temp,"comparisonH.meta.csv") # SpatialDE # https://protect-au.mimecast.com/s/-zOOCWLVEjtX9E82fwl5tK?domain=github.com cd /data/johnsonko source /data/johnsonko/conda/etc/profile.d/conda.sh conda activate base conda activate project2 pip install openpyxl sinteractive --mem 500g --time 36:00:00 --gres=lscratch:500 python import matplotlib.pyplot as plt import pandas as pd import NaiveDE import SpatialDE counts = pd.read_csv('comparisonH.csv', index_col=0) sample_info = pd.read_csv('comparisonH.meta.csv', index_col=0) sample_info sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_h_round1.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_h_round2.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_h_round3.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_h_round4.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_h_round5.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_h_round6.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_h_round7.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_h_round8.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_h_round9.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_h_round10.xlsx') exit() conda deactivate conda deactivate # crunch library("openxlsx") library("xlsx") rnd1 <- read.xlsx("comparison_h_round1.xlsx","Sheet1",stringsAsFactors = T) rnd2 <- read.xlsx("comparison_h_round2.xlsx","Sheet1",stringsAsFactors = T) rnd3 <- read.xlsx("comparison_h_round3.xlsx","Sheet1",stringsAsFactors = T) rnd4 <- read.xlsx("comparison_h_round4.xlsx","Sheet1",stringsAsFactors = T) rnd5 <- read.xlsx("comparison_h_round5.xlsx","Sheet1",stringsAsFactors = T) rnd6 <- read.xlsx("comparison_h_round6.xlsx","Sheet1",stringsAsFactors = T) rnd7 <- read.xlsx("comparison_h_round7.xlsx","Sheet1",stringsAsFactors = T) rnd8 <- read.xlsx("comparison_h_round8.xlsx","Sheet1",stringsAsFactors = T) rnd9 <- read.xlsx("comparison_h_round9.xlsx","Sheet1",stringsAsFactors = T) rnd10 <- read.xlsx("comparison_h_round10.xlsx","Sheet1",stringsAsFactors = T) dimnames(rnd1)[[1]] <- rnd1$g dimnames(rnd2)[[1]] <- rnd2$g dimnames(rnd3)[[1]] <- rnd3$g dimnames(rnd4)[[1]] <- rnd4$g dimnames(rnd5)[[1]] <- rnd5$g dimnames(rnd6)[[1]] <- rnd6$g dimnames(rnd7)[[1]] <- rnd7$g dimnames(rnd8)[[1]] <- rnd8$g dimnames(rnd9)[[1]] <- rnd9$g dimnames(rnd10)[[1]] <- rnd10$g rnd2 <- rnd2[dimnames(rnd2)[[1]],] rnd3 <- rnd2[dimnames(rnd3)[[1]],] rnd4 <- rnd2[dimnames(rnd4)[[1]],] rnd5 <- rnd2[dimnames(rnd5)[[1]],] rnd6 <- rnd2[dimnames(rnd6)[[1]],] rnd7 <- rnd2[dimnames(rnd7)[[1]],] rnd8 <- rnd2[dimnames(rnd8)[[1]],] rnd9 <- rnd2[dimnames(rnd9)[[1]],] rnd10 <- rnd2[dimnames(rnd10)[[1]],] rnd.cx <- cbind(rnd1$LLR,rnd2$LLR,rnd3$LLR,rnd4$LLR,rnd5$LLR,rnd6$LLR,rnd7$LLR,rnd8$LLR,rnd9$LLR,rnd10$LLR) dimnames(rnd.cx)[[1]] <- dimnames(rnd1)[[1]] rnd.cx.mean <- apply(rnd.cx,1,mean) rnd.cx.sd <- apply(rnd.cx,1,sd) rnd.cx.se <- https://protect-au.mimecast.com/s/T-okCYW8JlTp17XQcDWUHe?domain=rnd.cx.sd rnd.cx.z <- NULL rnd.cx.p <- NULL for (i in 1:length(rnd.cx.mean)) { rnd.temp1 <- (rnd.cx.mean[i]-mean(rnd.cx.mean[-c(i)]))/sd(rnd.cx.mean[-c(i)]) rnd.cx.z <- c(rnd.cx.z,rnd.temp1) rnd.temp1 <- 1-pnorm(rnd.temp1) rnd.cx.p <- c(rnd.cx.p,rnd.temp1) } rnd.cx.final <- cbind(rnd.cx.mean,rnd.cx.sd,rnd.cx.se,rnd.cx.z,rnd.cx.p) write.table(rnd.cx.final,"comparison_h_bootstrap_stats.txt",sep="\t") ############################################################################ # Comparison I # Group 8 vs Groups 1, 2, 3, 4, 5, 6, 7 # Cluster 8 vs clusters 0, 1, 4, 14, 2, 3, 6, 7, 11, 13, 15, 9, 16 ############################################################################ temp <- as.character(unlist(pbmc.Control.H250.185$seurat_clusters)) temp <- ifelse(temp=="0","B",temp) temp <- ifelse(temp=="1","B",temp) temp <- ifelse(temp=="2","B",temp) temp <- ifelse(temp=="3","B",temp) temp <- ifelse(temp=="4","B",temp) temp <- ifelse(temp=="5","X",temp) temp <- ifelse(temp=="6","B",temp) temp <- ifelse(temp=="7","B",temp) temp <- ifelse(temp=="8","A",temp) temp <- ifelse(temp=="9","B",temp) temp <- ifelse(temp=="10","X",temp) temp <- ifelse(temp=="11","B",temp) temp <- ifelse(temp=="12","X",temp) temp <- ifelse(temp=="13","B",temp) temp <- ifelse(temp=="14","B",temp) temp <- ifelse(temp=="15","B",temp) temp <- ifelse(temp=="16","B",temp) temp <- ifelse(temp=="17","X",temp) temp <- ifelse(temp=="18","X",temp) temp <- ifelse(temp=="19","X",temp) temp <- ifelse(temp=="20","X",temp) temp <- ifelse(temp=="21","X",temp) temp <- ifelse(temp=="22","X",temp) temp <- ifelse(temp=="23","X",temp) temp <- ifelse(temp=="24","X",temp) temp <- ifelse(temp=="25","X",temp) pbmc.Control.H250.185@meta.data$comparisonA <- as.factor(temp) temp <- pbmc.Control.H250.185[,pbmc.Control.H250.185@meta.data$comparisonA!="X"] temp.data <- GetAssayData(temp, slot = "counts") temp.data <- as.matrix(temp.data) temp.data <- t(temp.data) temp <- dimnames(temp.data)[[1]] temp <- str_replace_all(temp,"X","x") dimnames(temp.data)[[1]] <- temp write.csv(temp.data,"comparisonI.csv") temp <- strsplit(temp,"x") temp <- as.data.frame(temp) temp <- t(temp) dimnames(temp)[[1]] <- dimnames(temp.data)[[1]] temp <- cbind(temp,apply(temp.data,1,sum)) dimnames(temp)[[2]] <- c("x","y","total_counts") write.csv(temp,"comparisonI.meta.csv") # SpatialDE # https://protect-au.mimecast.com/s/-zOOCWLVEjtX9E82fwl5tK?domain=github.com cd /data/johnsonko source /data/johnsonko/conda/etc/profile.d/conda.sh conda activate base conda activate project2 pip install openpyxl sinteractive --mem 500g --time 36:00:00 --gres=lscratch:500 python import matplotlib.pyplot as plt import pandas as pd import NaiveDE import SpatialDE counts = pd.read_csv('comparisonI.csv', index_col=0) sample_info = pd.read_csv('comparisonI.meta.csv', index_col=0) sample_info sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_i_round1.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_i_round2.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_i_round3.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_i_round4.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_i_round5.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_i_round6.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_i_round7.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_i_round8.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_i_round9.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_i_round10.xlsx') exit() conda deactivate conda deactivate # crunch library("openxlsx") library("xlsx") rnd1 <- read.xlsx("comparison_i_round1.xlsx","Sheet1",stringsAsFactors = T) rnd2 <- read.xlsx("comparison_i_round2.xlsx","Sheet1",stringsAsFactors = T) rnd3 <- read.xlsx("comparison_i_round3.xlsx","Sheet1",stringsAsFactors = T) rnd4 <- read.xlsx("comparison_i_round4.xlsx","Sheet1",stringsAsFactors = T) rnd5 <- read.xlsx("comparison_i_round5.xlsx","Sheet1",stringsAsFactors = T) rnd6 <- read.xlsx("comparison_i_round6.xlsx","Sheet1",stringsAsFactors = T) rnd7 <- read.xlsx("comparison_i_round7.xlsx","Sheet1",stringsAsFactors = T) rnd8 <- read.xlsx("comparison_i_round8.xlsx","Sheet1",stringsAsFactors = T) rnd9 <- read.xlsx("comparison_i_round9.xlsx","Sheet1",stringsAsFactors = T) rnd10 <- read.xlsx("comparison_i_round10.xlsx","Sheet1",stringsAsFactors = T) dimnames(rnd1)[[1]] <- rnd1$g dimnames(rnd2)[[1]] <- rnd2$g dimnames(rnd3)[[1]] <- rnd3$g dimnames(rnd4)[[1]] <- rnd4$g dimnames(rnd5)[[1]] <- rnd5$g dimnames(rnd6)[[1]] <- rnd6$g dimnames(rnd7)[[1]] <- rnd7$g dimnames(rnd8)[[1]] <- rnd8$g dimnames(rnd9)[[1]] <- rnd9$g dimnames(rnd10)[[1]] <- rnd10$g rnd2 <- rnd2[dimnames(rnd2)[[1]],] rnd3 <- rnd2[dimnames(rnd3)[[1]],] rnd4 <- rnd2[dimnames(rnd4)[[1]],] rnd5 <- rnd2[dimnames(rnd5)[[1]],] rnd6 <- rnd2[dimnames(rnd6)[[1]],] rnd7 <- rnd2[dimnames(rnd7)[[1]],] rnd8 <- rnd2[dimnames(rnd8)[[1]],] rnd9 <- rnd2[dimnames(rnd9)[[1]],] rnd10 <- rnd2[dimnames(rnd10)[[1]],] rnd.cx <- cbind(rnd1$LLR,rnd2$LLR,rnd3$LLR,rnd4$LLR,rnd5$LLR,rnd6$LLR,rnd7$LLR,rnd8$LLR,rnd9$LLR,rnd10$LLR) dimnames(rnd.cx)[[1]] <- dimnames(rnd1)[[1]] rnd.cx.mean <- apply(rnd.cx,1,mean) rnd.cx.sd <- apply(rnd.cx,1,sd) rnd.cx.se <- https://protect-au.mimecast.com/s/T-okCYW8JlTp17XQcDWUHe?domain=rnd.cx.sd rnd.cx.z <- NULL rnd.cx.p <- NULL for (i in 1:length(rnd.cx.mean)) { rnd.temp1 <- (rnd.cx.mean[i]-mean(rnd.cx.mean[-c(i)]))/sd(rnd.cx.mean[-c(i)]) rnd.cx.z <- c(rnd.cx.z,rnd.temp1) rnd.temp1 <- 1-pnorm(rnd.temp1) rnd.cx.p <- c(rnd.cx.p,rnd.temp1) } rnd.cx.final <- cbind(rnd.cx.mean,rnd.cx.sd,rnd.cx.se,rnd.cx.z,rnd.cx.p) write.table(rnd.cx.final,"comparison_i_bootstrap_stats.txt",sep="\t") ############################################################################ # Comparison J # Group 8 vs Groups 1, 2, 3, 4, 5, 6, 7 # Cluster 12 vs clusters 0, 1, 4, 14, 2, 3, 6, 7, 11, 13, 15, 9, 16 ############################################################################ temp <- as.character(unlist(pbmc.Control.H250.185$seurat_clusters)) temp <- ifelse(temp=="0","B",temp) temp <- ifelse(temp=="1","B",temp) temp <- ifelse(temp=="2","B",temp) temp <- ifelse(temp=="3","B",temp) temp <- ifelse(temp=="4","B",temp) temp <- ifelse(temp=="5","X",temp) temp <- ifelse(temp=="6","B",temp) temp <- ifelse(temp=="7","B",temp) temp <- ifelse(temp=="8","X",temp) temp <- ifelse(temp=="9","B",temp) temp <- ifelse(temp=="10","X",temp) temp <- ifelse(temp=="11","B",temp) temp <- ifelse(temp=="12","A",temp) temp <- ifelse(temp=="13","B",temp) temp <- ifelse(temp=="14","B",temp) temp <- ifelse(temp=="15","B",temp) temp <- ifelse(temp=="16","B",temp) temp <- ifelse(temp=="17","X",temp) temp <- ifelse(temp=="18","X",temp) temp <- ifelse(temp=="19","X",temp) temp <- ifelse(temp=="20","X",temp) temp <- ifelse(temp=="21","X",temp) temp <- ifelse(temp=="22","X",temp) temp <- ifelse(temp=="23","X",temp) temp <- ifelse(temp=="24","X",temp) temp <- ifelse(temp=="25","X",temp) pbmc.Control.H250.185@meta.data$comparisonA <- as.factor(temp) temp <- pbmc.Control.H250.185[,pbmc.Control.H250.185@meta.data$comparisonA!="X"] temp.data <- GetAssayData(temp, slot = "counts") temp.data <- as.matrix(temp.data) temp.data <- t(temp.data) temp <- dimnames(temp.data)[[1]] temp <- str_replace_all(temp,"X","x") dimnames(temp.data)[[1]] <- temp write.csv(temp.data,"comparisonJ.csv") temp <- strsplit(temp,"x") temp <- as.data.frame(temp) temp <- t(temp) dimnames(temp)[[1]] <- dimnames(temp.data)[[1]] temp <- cbind(temp,apply(temp.data,1,sum)) dimnames(temp)[[2]] <- c("x","y","total_counts") write.csv(temp,"comparisonJ.meta.csv") # SpatialDE # https://protect-au.mimecast.com/s/-zOOCWLVEjtX9E82fwl5tK?domain=github.com cd /data/johnsonko source /data/johnsonko/conda/etc/profile.d/conda.sh conda activate base conda activate project2 pip install openpyxl sinteractive --mem 500g --time 36:00:00 --gres=lscratch:500 python import matplotlib.pyplot as plt import pandas as pd import NaiveDE import SpatialDE counts = pd.read_csv('comparisonJ.csv', index_col=0) sample_info = pd.read_csv('comparisonJ.meta.csv', index_col=0) sample_info sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_j_round1.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_j_round2.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_j_round3.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_j_round4.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_j_round5.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_j_round6.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_j_round7.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_j_round8.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_j_round9.xlsx') sampled_sample_info = sample_info.sample(3000) sampled_counts = counts.loc[sampled_sample_info.index] norm_expr = NaiveDE.stabilize(sampled_counts.T).T resid_expr = NaiveDE.regress_out(sampled_sample_info, norm_expr.T, 'np.log(total_counts)', rcond=1e-4).T X = sampled_sample_info[['x', 'y']] results = "" results = SpatialDE.run(X, resid_expr) results.to_excel('comparison_j_round10.xlsx') exit() conda deactivate conda deactivate # crunch library("openxlsx") library("xlsx") rnd1 <- read.xlsx("comparison_j_round1.xlsx","Sheet1",stringsAsFactors = T) rnd2 <- read.xlsx("comparison_j_round2.xlsx","Sheet1",stringsAsFactors = T) rnd3 <- read.xlsx("comparison_j_round3.xlsx","Sheet1",stringsAsFactors = T) rnd4 <- read.xlsx("comparison_j_round4.xlsx","Sheet1",stringsAsFactors = T) rnd5 <- read.xlsx("comparison_j_round5.xlsx","Sheet1",stringsAsFactors = T) rnd6 <- read.xlsx("comparison_j_round6.xlsx","Sheet1",stringsAsFactors = T) rnd7 <- read.xlsx("comparison_j_round7.xlsx","Sheet1",stringsAsFactors = T) rnd8 <- read.xlsx("comparison_j_round8.xlsx","Sheet1",stringsAsFactors = T) rnd9 <- read.xlsx("comparison_j_round9.xlsx","Sheet1",stringsAsFactors = T) rnd10 <- read.xlsx("comparison_j_round10.xlsx","Sheet1",stringsAsFactors = T) dimnames(rnd1)[[1]] <- rnd1$g dimnames(rnd2)[[1]] <- rnd2$g dimnames(rnd3)[[1]] <- rnd3$g dimnames(rnd4)[[1]] <- rnd4$g dimnames(rnd5)[[1]] <- rnd5$g dimnames(rnd6)[[1]] <- rnd6$g dimnames(rnd7)[[1]] <- rnd7$g dimnames(rnd8)[[1]] <- rnd8$g dimnames(rnd9)[[1]] <- rnd9$g dimnames(rnd10)[[1]] <- rnd10$g rnd2 <- rnd2[dimnames(rnd2)[[1]],] rnd3 <- rnd2[dimnames(rnd3)[[1]],] rnd4 <- rnd2[dimnames(rnd4)[[1]],] rnd5 <- rnd2[dimnames(rnd5)[[1]],] rnd6 <- rnd2[dimnames(rnd6)[[1]],] rnd7 <- rnd2[dimnames(rnd7)[[1]],] rnd8 <- rnd2[dimnames(rnd8)[[1]],] rnd9 <- rnd2[dimnames(rnd9)[[1]],] rnd10 <- rnd2[dimnames(rnd10)[[1]],] rnd.cx <- cbind(rnd1$LLR,rnd2$LLR,rnd3$LLR,rnd4$LLR,rnd5$LLR,rnd6$LLR,rnd7$LLR,rnd8$LLR,rnd9$LLR,rnd10$LLR) dimnames(rnd.cx)[[1]] <- dimnames(rnd1)[[1]] rnd.cx.mean <- apply(rnd.cx,1,mean) rnd.cx.sd <- apply(rnd.cx,1,sd) rnd.cx.se <- https://protect-au.mimecast.com/s/T-okCYW8JlTp17XQcDWUHe?domain=rnd.cx.sd rnd.cx.z <- NULL rnd.cx.p <- NULL for (i in 1:length(rnd.cx.mean)) { rnd.temp1 <- (rnd.cx.mean[i]-mean(rnd.cx.mean[-c(i)]))/sd(rnd.cx.mean[-c(i)]) rnd.cx.z <- c(rnd.cx.z,rnd.temp1) rnd.temp1 <- 1-pnorm(rnd.temp1) rnd.cx.p <- c(rnd.cx.p,rnd.temp1) } rnd.cx.final <- cbind(rnd.cx.mean,rnd.cx.sd,rnd.cx.se,rnd.cx.z,rnd.cx.p) write.table(rnd.cx.final,"comparison_j_bootstrap_stats.txt",sep="\t") ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## # Cross Bulb Seurat Analysis - 20201006 ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## ############################################## # https://protect-au.mimecast.com/s/bTpdCZY1Kmh846YEsoyrGL?domain=satijalab.org # https://protect-au.mimecast.com/s/Zpd-C1WLoBTBz4X1iwmjof?domain=rdrr.io pbmc.merged <- merge(x=pbmc.AZ.109.146,y=c(pbmc.AZ.84.145, pbmc.AZ.90.242, pbmc.AZ.99.140, pbmc.AZ.251.146, pbmc.Control.H190.260, pbmc.Control.H250.185, pbmc.Control.OFB57.194, pbmc.Control.OFB6A.107, pbmc.PD.52.247, pbmc.PD.56.236, pbmc.PD.58.229, pbmc.PD.77.197, pbmc.PD.79.201), add.cell.ids=c("AZ.109.146", "AZ.84.145", "AZ.90.242", "AZ.99.140", "AZ.251.146", "Control.H190.260", "Control.H250.185", "Control.OFB57.194", "Control.OFB6A.107", "PD.52.247", "PD.56.236", "PD.58.229", "PD.77.197", "PD.79.201")) DefaultAssay(pbmc.merged) <- "SCT" VariableFeatures(pbmc.merged) <- sort(unique(c(VariableFeatures(pbmc.AZ.109.146), VariableFeatures(pbmc.AZ.84.145), VariableFeatures(pbmc.AZ.90.242), VariableFeatures(pbmc.AZ.99.140), VariableFeatures(pbmc.AZ.251.146), VariableFeatures(pbmc.Control.H190.260), VariableFeatures(pbmc.Control.H250.185), VariableFeatures(pbmc.Control.OFB57.194), VariableFeatures(pbmc.Control.OFB6A.107), VariableFeatures(pbmc.PD.52.247), VariableFeatures(pbmc.PD.56.236), VariableFeatures(pbmc.PD.58.229), VariableFeatures(pbmc.PD.77.197), VariableFeatures(pbmc.PD.79.201)))) pbmc.merged <- RunPCA(pbmc.merged,verbose=FALSE,approx=FALSE) e <- ElbowPlot(pbmc.merged, ndims=dim(pbmc.merged$pca)[2],reduction="pca") e <- e[[1]] e <- e[e[,2]>1,] e <- max(e[,1]) dims2use <- e pbmc.merged <- FindNeighbors(pbmc.merged, dims = 1:dims2use) pbmc.merged <- FindClusters(pbmc.merged, verbose = FALSE) pbmc.merged <- RunUMAP(pbmc.merged, dims = 1:dims2use) temp <- dimnames(pbmc.merged@meta.data)[[1]] temp <- strsplit(temp,"_") temp <- as.data.frame(temp) temp <- t(temp) temp <- temp[,1] temp <- as.character(unlist(temp)) pbmc.merged@meta.data$Sample <- temp ############### # UMAP Plots ############### tiff("Combined_Sample_UMAP_Plot_Not_Split_Out_Label_Yes_Legend_Yes.tiff") print(DimPlot(pbmc.merged,reduction="umap",label = TRUE)) dev.off() tiff("Combined_Sample_UMAP_Plot_Not_Split_Out_Label_No_Legend_Yes.tiff") print(DimPlot(pbmc.merged,reduction="umap",label = FALSE) + NoLegend()) dev.off() tiff("Combined_Sample_UMAP_Plot_Not_Split_Out_Label_No_Legend_No.tiff") print(DimPlot(pbmc.merged,reduction="umap",label = FALSE) + NoLegend()) dev.off() tiff("Combined_Sample_UMAP_Plot_Split_Out_Label_No_Legend_No.tiff") print(DimPlot(pbmc.merged,reduction="umap",label = FALSE,split.by="Sample",ncol=4) + NoLegend()) dev.off() tiff("Combined_Sample_UMAP_Plot_Split_Out_Label_By_Sample.tiff") print(DimPlot(pbmc.merged,reduction="umap",label = FALSE,split.by="Sample",group.by="Sample",ncol=4) + NoLegend()) dev.off() tiff("Combined_Sample_UMAP_Plot_Split_Out_Label_By_Sample_With_Legend.tiff") print(DimPlot(pbmc.merged,reduction="umap",label = FALSE,split.by="Sample",group.by="Sample",ncol=4)) dev.off() tiff("Combined_Sample_UMAP_Plot_Split_Out_Label_By_Sample_With_Legend.tiff") print(DimPlot(pbmc.merged,reduction="umap",label = FALSE,split.by="seurat_clusters",group.by="Sample",ncol=4)) dev.off() print(FeaturePlot(pbmc.merged,features="TAU",split.by="Sample",ncol=4) + NoLegend()) ############### # Feature Plots ############### tiff("Combined_Sample_Feature_Plot_ALPHA_SYNUCLEIN.tiff") print(FeaturePlot(pbmc.merged, features = c("ALPHA-SYNUCLEIN"))) dev.off() tiff("Combined_Sample_Feature_Plot_BETA_AMYLOID.tiff") print(FeaturePlot(pbmc.merged, features = c("BETA-AMYLOID"))) dev.off() tiff("Combined_Sample_Feature_Plot_CALBINDIN.tiff") print(FeaturePlot(pbmc.merged, features = c("CALBINDIN"))) dev.off() tiff("Combined_Sample_Feature_Plot_CD31.tiff") print(FeaturePlot(pbmc.merged, features = c("CD31"))) dev.off() tiff("Combined_Sample_Feature_Plot_CH_NEUN.tiff") print(FeaturePlot(pbmc.merged, features = c("CH-NEUN"))) dev.off() tiff("Combined_Sample_Feature_Plot_CNPASE.tiff") print(FeaturePlot(pbmc.merged, features = c("CNPASE"))) dev.off() tiff("Combined_Sample_Feature_Plot_COLLAGEN_IV.tiff") print(FeaturePlot(pbmc.merged, features = c("COLLAGEN-IV"))) dev.off() tiff("Combined_Sample_Feature_Plot_DAPI.tiff") print(FeaturePlot(pbmc.merged, features = c("DAPI"))) dev.off() tiff("Combined_Sample_Feature_Plot_GFAP.tiff") print(FeaturePlot(pbmc.merged, features = c("GFAP"))) dev.off() tiff("Combined_Sample_Feature_Plot_HISTONES.tiff") print(FeaturePlot(pbmc.merged, features = c("HISTONES"))) dev.off() tiff("Combined_Sample_Feature_Plot_HLADR.tiff") print(FeaturePlot(pbmc.merged, features = c("HLADR"))) dev.off() tiff("Combined_Sample_Feature_Plot_IBA1.tiff") print(FeaturePlot(pbmc.merged, features = c("IBA1"))) dev.off() tiff("Combined_Sample_Feature_Plot_MAP2.tiff") print(FeaturePlot(pbmc.merged, features = c("MAP2"))) dev.off() tiff("Combined_Sample_Feature_Plot_MBP.tiff") print(FeaturePlot(pbmc.merged, features = c("MBP"))) dev.off() tiff("Combined_Sample_Feature_Plot_NEURO_HEAVY.tiff") print(FeaturePlot(pbmc.merged, features = c("NEURO-HEAVY"))) dev.off() tiff("Combined_Sample_Feature_Plot_NEURO_LIGHT.tiff") print(FeaturePlot(pbmc.merged, features = c("NEURO-LIGHT"))) dev.off() tiff("Combined_Sample_Feature_Plot_OMP.tiff") print(FeaturePlot(pbmc.merged, features = c("OMP"))) dev.off() tiff("Combined_Sample_Feature_Plot_PGP9_5.tiff") print(FeaturePlot(pbmc.merged, features = c("PGP9-5"))) dev.off() tiff("Combined_Sample_Feature_Plot_RB_CALRETININ.tiff") print(FeaturePlot(pbmc.merged, features = c("RB-CALRETININ"))) dev.off() tiff("Combined_Sample_Feature_Plot_S100.tiff") print(FeaturePlot(pbmc.merged, features = c("S100"))) dev.off() tiff("Combined_Sample_Feature_Plot_SYNAPTOPHYSIN.tiff") print(FeaturePlot(pbmc.merged, features = c("SYNAPTOPHYSIN"))) dev.off() tiff("Combined_Sample_Feature_Plot_TAU.tiff") print(FeaturePlot(pbmc.merged, features = c("TAU"))) dev.off() tiff("Combined_Sample_Feature_Plot_TOMATO_LECTIN.tiff") print(FeaturePlot(pbmc.merged, features = c("TOMATO-LECTIN"))) dev.off() tiff("Combined_Sample_Feature_Plot_TYR_HYDROXYLASE.tiff") print(FeaturePlot(pbmc.merged, features = c("TYR-HYDROXYLASE"))) dev.off() tiff("Combined_Sample_Feature_Plot_UEA_LECTIN.tiff") print(FeaturePlot(pbmc.merged, features = c("UEA-LECTIN"))) dev.off() ############# # Ridge Plots ############# tiff("Combined_Sample_Ridge_Plot_ALPHA_SYNUCLEIN.tiff") print(RidgePlot(pbmc.merged, features = c("ALPHA-SYNUCLEIN"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_BETA_AMYLOID.tiff") print(RidgePlot(pbmc.merged, features = c("BETA-AMYLOID"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_CALBINDIN.tiff") print(RidgePlot(pbmc.merged, features = c("CALBINDIN"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_CD31.tiff") print(RidgePlot(pbmc.merged, features = c("CD31"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_CH_NEUN.tiff") print(RidgePlot(pbmc.merged, features = c("CH-NEUN"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_CNPASE.tiff") print(RidgePlot(pbmc.merged, features = c("CNPASE"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_COLLAGEN_IV.tiff") print(RidgePlot(pbmc.merged, features = c("COLLAGEN-IV"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_DAPI.tiff") print(RidgePlot(pbmc.merged, features = c("DAPI"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_GFAP.tiff") print(RidgePlot(pbmc.merged, features = c("GFAP"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_HISTONES.tiff") print(RidgePlot(pbmc.merged, features = c("HISTONES"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_HLADR.tiff") print(RidgePlot(pbmc.merged, features = c("HLADR"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_IBA1.tiff") print(RidgePlot(pbmc.merged, features = c("IBA1"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_MAP2.tiff") print(RidgePlot(pbmc.merged, features = c("MAP2"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_MBP.tiff") print(RidgePlot(pbmc.merged, features = c("MBP"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_NEURO_HEAVY.tiff") print(RidgePlot(pbmc.merged, features = c("NEURO-HEAVY"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_NEURO_LIGHT.tiff") print(RidgePlot(pbmc.merged, features = c("NEURO-LIGHT"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_OMP.tiff") print(RidgePlot(pbmc.merged, features = c("OMP"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_PGP9_5.tiff") print(RidgePlot(pbmc.merged, features = c("PGP9-5"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_RB_CALRETININ.tiff") print(RidgePlot(pbmc.merged, features = c("RB-CALRETININ"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_S100.tiff") print(RidgePlot(pbmc.merged, features = c("S100"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_SYNAPTOPHYSIN.tiff") print(RidgePlot(pbmc.merged, features = c("SYNAPTOPHYSIN"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_TAU.tiff") print(RidgePlot(pbmc.merged, features = c("TAU"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_TOMATO_LECTIN.tiff") print(RidgePlot(pbmc.merged, features = c("TOMATO-LECTIN"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_TYR_HYDROXYLASE.tiff") print(RidgePlot(pbmc.merged, features = c("TYR-HYDROXYLASE"),group.by="Sample") + NoLegend()) dev.off() tiff("Combined_Sample_Ridge_Plot_UEA_LECTIN.tiff") print(RidgePlot(pbmc.merged, features = c("UEA-LECTIN"),group.by="Sample") + NoLegend()) dev.off() ############# # Violin Plots ############# tiff("Combined_Sample_Violin_Plot_ALPHA_SYNUCLEIN.tiff") print(VlnPlot(pbmc.merged, features = c("ALPHA-SYNUCLEIN"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_BETA_AMYLOID.tiff") print(VlnPlot(pbmc.merged, features = c("BETA-AMYLOID"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_CALBINDIN.tiff") print(VlnPlot(pbmc.merged, features = c("CALBINDIN"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_CD31.tiff") print(VlnPlot(pbmc.merged, features = c("CD31"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_CH_NEUN.tiff") print(VlnPlot(pbmc.merged, features = c("CH-NEUN"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_CNPASE.tiff") print(VlnPlot(pbmc.merged, features = c("CNPASE"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_COLLAGEN_IV.tiff") print(VlnPlot(pbmc.merged, features = c("COLLAGEN-IV"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_DAPI.tiff") print(VlnPlot(pbmc.merged, features = c("DAPI"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_GFAP.tiff") print(VlnPlot(pbmc.merged, features = c("GFAP"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_HISTONES.tiff") print(VlnPlot(pbmc.merged, features = c("HISTONES"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_HLADR.tiff") print(VlnPlot(pbmc.merged, features = c("HLADR"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_IBA1.tiff") print(VlnPlot(pbmc.merged, features = c("IBA1"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_MAP2.tiff") print(VlnPlot(pbmc.merged, features = c("MAP2"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_MBP.tiff") print(VlnPlot(pbmc.merged, features = c("MBP"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_NEURO_HEAVY.tiff") print(VlnPlot(pbmc.merged, features = c("NEURO-HEAVY"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_NEURO_LIGHT.tiff") print(VlnPlot(pbmc.merged, features = c("NEURO-LIGHT"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_OMP.tiff") print(VlnPlot(pbmc.merged, features = c("OMP"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_PGP9_5.tiff") print(VlnPlot(pbmc.merged, features = c("PGP9-5"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_RB_CALRETININ.tiff") print(VlnPlot(pbmc.merged, features = c("RB-CALRETININ"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_S100.tiff") print(VlnPlot(pbmc.merged, features = c("S100"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_SYNAPTOPHYSIN.tiff") print(VlnPlot(pbmc.merged, features = c("SYNAPTOPHYSIN"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_TAU.tiff") print(VlnPlot(pbmc.merged, features = c("TAU"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_TOMATO_LECTIN.tiff") print(VlnPlot(pbmc.merged, features = c("TOMATO-LECTIN"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_TYR_HYDROXYLASE.tiff") print(VlnPlot(pbmc.merged, features = c("TYR-HYDROXYLASE"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() tiff("Combined_Sample_Violin_Plot_UEA_LECTIN.tiff") print(VlnPlot(pbmc.merged, features = c("UEA-LECTIN"),group.by="Sample",pt.size=0) + NoLegend()) dev.off() ########## # Dot Plot ########## tiff("Combined_Sample_Dot_Plot_By_Sample_By_Label.tiff",width = 12, height = 6, units = "in",res=300) print(DotPlot(pbmc.merged, features = rownames(pbmc.merged),group.by="Sample") + RotatedAxis()) dev.off() tiff("Combined_Sample_Dot_Plot_By_Sample_By_Label.tiff",width = 12, height = 12, units = "in",res=300) print(DotPlot(pbmc.merged, features = rownames(pbmc.merged),group.by="seurat_clusters") + RotatedAxis()) dev.off() ########## # Class Definition ########## temp <- dimnames(pbmc.merged@meta.data)[[1]] temp <- strsplit(temp,"_") temp <- as.data.frame(temp) temptemp <- temp[1,] temp <- as.character(unlist(temptemp)) temptemp <- strsplit(temp,".",fixed=TRUE) temp <- as.data.frame(temptemp) temptemp <- temp[1,] temptemp <- as.character(unlist(temptemp)) pbmc.merged@meta.data$Class <- temptemp ########## # Dot Plot ########## tiff("Combined_Sample_Dot_Plot_By_Class_By_Label.tiff",width = 12, height = 6, units = "in",res=300) print(DotPlot(pbmc.merged, features = rownames(pbmc.merged),group.by="Class") + RotatedAxis()) dev.off() ########## # UMAP Plot ########## tiff("UMAP_By_Class.tiff") print(DimPlot(pbmc.merged,reduction="umap",split.by="Class",group.by="Class")) dev.off() ############### # Feature Plots ############### tiff("FeaturePlot_By_Class_For_ALPHA_SYNUCLEIN.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("ALPHA-SYNUCLEIN"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_BETA_AMYLOID.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("BETA-AMYLOID"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_CALBINDIN.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("CALBINDIN"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_CD31.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("CD31"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_CH_NEUN.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("CH-NEUN"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_CNPASE.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("CNPASE"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_COLLAGEN_IV.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("COLLAGEN-IV"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_DAPI.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("DAPI"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_GFAP.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("GFAP"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_HISTONES.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("HISTONES"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_HLADR.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("HLADR"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_IBA1.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("IBA1"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_MAP2.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("MAP2"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_MBP.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("MBP"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_NEURO_HEAVY.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("NEURO-HEAVY"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_NEURO_LIGHT.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("NEURO-LIGHT"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_OMP.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("OMP"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_PGP9_5.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("PGP9-5"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_RB_CALRETININ.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("RB-CALRETININ"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_S100.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("S100"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_SYNAPTOPHYSIN.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("SYNAPTOPHYSIN"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_TAU.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("TAU"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_TOMATO_LECTIN.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("TOMATO-LECTIN"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_TYR_HYDROXYLASE.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("TYR-HYDROXYLASE"),split.by="Class")) dev.off() tiff("FeaturePlot_By_Class_For_UEA_LECTIN.tiff",width = 12, height = 6, units = "in",res=300) print(FeaturePlot(pbmc.merged, features = c("UEA-LECTIN"),split.by="Class")) dev.off() ############# # Ridge Plots ############# tiff("Ridge_Plot_By_Class_For_ALPHA_SYNUCLEIN.tiff") print(RidgePlot(pbmc.merged, features = c("ALPHA-SYNUCLEIN"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_BETA_AMYLOID.tiff") print(RidgePlot(pbmc.merged, features = c("BETA-AMYLOID"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_CALBINDIN.tiff") print(RidgePlot(pbmc.merged, features = c("CALBINDIN"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_CD31.tiff") print(RidgePlot(pbmc.merged, features = c("CD31"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_CH_NEUN.tiff") print(RidgePlot(pbmc.merged, features = c("CH-NEUN"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_CNPASE.tiff") print(RidgePlot(pbmc.merged, features = c("CNPASE"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_COLLAGEN_IV.tiff") print(RidgePlot(pbmc.merged, features = c("COLLAGEN-IV"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_DAPI.tiff") print(RidgePlot(pbmc.merged, features = c("DAPI"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_GFAP.tiff") print(RidgePlot(pbmc.merged, features = c("GFAP"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_HISTONES.tiff") print(RidgePlot(pbmc.merged, features = c("HISTONES"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_HLADR.tiff") print(RidgePlot(pbmc.merged, features = c("HLADR"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_IBA1.tiff") print(RidgePlot(pbmc.merged, features = c("IBA1"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_MAP2.tiff") print(RidgePlot(pbmc.merged, features = c("MAP2"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_MBP.tiff") print(RidgePlot(pbmc.merged, features = c("MBP"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_NEURO_HEAVY.tiff") print(RidgePlot(pbmc.merged, features = c("NEURO-HEAVY"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_NEURO_LIGHT.tiff") print(RidgePlot(pbmc.merged, features = c("NEURO-LIGHT"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_OMP.tiff") print(RidgePlot(pbmc.merged, features = c("OMP"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_PGP9_5.tiff") print(RidgePlot(pbmc.merged, features = c("PGP9-5"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_RB_CALRETININ.tiff") print(RidgePlot(pbmc.merged, features = c("RB-CALRETININ"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_S100.tiff") print(RidgePlot(pbmc.merged, features = c("S100"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_SYNAPTOPHYSIN.tiff") print(RidgePlot(pbmc.merged, features = c("SYNAPTOPHYSIN"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_TAU.tiff") print(RidgePlot(pbmc.merged, features = c("TAU"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_TOMATO_LECTIN.tiff") print(RidgePlot(pbmc.merged, features = c("TOMATO-LECTIN"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_TYR_HYDROXYLASE.tiff") print(RidgePlot(pbmc.merged, features = c("TYR-HYDROXYLASE"),group.by="Class") + NoLegend()) dev.off() tiff("Ridge_Plot_By_Class_For_UEA_LECTIN.tiff") print(RidgePlot(pbmc.merged, features = c("UEA-LECTIN"),group.by="Class") + NoLegend()) dev.off() ############# # Violin Plots ############# tiff("Violin_Plot_By_Class_For_ALPHA_SYNUCLEIN.tiff") print(VlnPlot(pbmc.merged, features = c("ALPHA-SYNUCLEIN"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_BETA_AMYLOID.tiff") print(VlnPlot(pbmc.merged, features = c("BETA-AMYLOID"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_CALBINDIN.tiff") print(VlnPlot(pbmc.merged, features = c("CALBINDIN"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_CD31.tiff") print(VlnPlot(pbmc.merged, features = c("CD31"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_CH_NEUN.tiff") print(VlnPlot(pbmc.merged, features = c("CH-NEUN"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_CNPASE.tiff") print(VlnPlot(pbmc.merged, features = c("CNPASE"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_COLLAGEN_IV.tiff") print(VlnPlot(pbmc.merged, features = c("COLLAGEN-IV"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_DAPI.tiff") print(VlnPlot(pbmc.merged, features = c("DAPI"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_GFAP.tiff") print(VlnPlot(pbmc.merged, features = c("GFAP"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_HISTONES.tiff") print(VlnPlot(pbmc.merged, features = c("HISTONES"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_HLADR.tiff") print(VlnPlot(pbmc.merged, features = c("HLADR"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_IBA1.tiff") print(VlnPlot(pbmc.merged, features = c("IBA1"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_MAP2.tiff") print(VlnPlot(pbmc.merged, features = c("MAP2"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_MBP.tiff") print(VlnPlot(pbmc.merged, features = c("MBP"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_NEURO_HEAVY.tiff") print(VlnPlot(pbmc.merged, features = c("NEURO-HEAVY"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_NEURO_LIGHT.tiff") print(VlnPlot(pbmc.merged, features = c("NEURO-LIGHT"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_OMP.tiff") print(VlnPlot(pbmc.merged, features = c("OMP"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_PGP9_5.tiff") print(VlnPlot(pbmc.merged, features = c("PGP9-5"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_RB_CALRETININ.tiff") print(VlnPlot(pbmc.merged, features = c("RB-CALRETININ"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_S100.tiff") print(VlnPlot(pbmc.merged, features = c("S100"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_SYNAPTOPHYSIN.tiff") print(VlnPlot(pbmc.merged, features = c("SYNAPTOPHYSIN"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_TAU.tiff") print(VlnPlot(pbmc.merged, features = c("TAU"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_TOMATO_LECTIN.tiff") print(VlnPlot(pbmc.merged, features = c("TOMATO-LECTIN"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_TYR_HYDROXYLASE.tiff") print(VlnPlot(pbmc.merged, features = c("TYR-HYDROXYLASE"),group.by="Class",pt.size=0) + NoLegend()) dev.off() tiff("Violin_Plot_By_Class_For_UEA_LECTIN.tiff") print(VlnPlot(pbmc.merged, features = c("UEA-LECTIN"),group.by="Class",pt.size=0) + NoLegend()) dev.off() ############################################## # Stacked BarChart # https://protect-au.mimecast.com/s/gm_LC2xMp1UZlYQvuZPKBD?domain=r-graph-gallery.com ############################################## library(ggplot2) library(viridis) running.stack <- NULL temp0 <- sort(unique(pbmc.merged@meta.data$seurat_clusters)) for (i in 1:length(temp0)) { print(i) temp1 <- pbmc.merged@meta.data$Class[pbmc.merged@meta.data$seurat_clusters==temp0[i]] temp2 <- table(temp1) if(length(intersect(names(temp2),"Control"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "Control" } if(length(intersect(names(temp2),"AZ"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "AZ" } if(length(intersect(names(temp2),"PD"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "PD" } temp2 <- temp2[c("Control","AZ","PD")] running.stack <- rbind(running.stack,temp2) } write.table(running.stack,"Number_Bins_Per_Cluster_By_Class.txt",sep="\t") running.stack <- cbind(temp0,running.stack) dimnames(running.stack)[[2]] <- c("Cluster","Control","AZ","PD") running.stack <- as.data.frame(running.stack) running.stack$Cluster <- as.factor(running.stack$Cluster) temp3 <- running.stack[,c(1,2)] temp3 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep("Control",dim(running.stack)[1]))),NumberCells=running.stack[,c(2)]) temp4 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep("AZ",dim(running.stack)[1]))),NumberCells=running.stack[,c(3)]) temp5 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep("PD",dim(running.stack)[1]))),NumberCells=running.stack[,c(4)]) temp6 <- rbind(temp4,temp3,temp5) temp7 <- temp6[order(temp6$Cluster), ] p1 <- ggplot(temp7, aes(fill=Sample, y=log2(NumberCells+2), x=Cluster)) + geom_bar(position="stack", stat="identity") + scale_fill_manual(values=hue_pal()(3)[c(1,2,3)]) + labs(y="Log2(Number Bins + 2)") + theme(panel.background = element_rect(fill = "white",colour = "white")) + geom_hline(yintercept=0, size=0.5) p1 tiff("Cluster_vs_Number_Bin_Bar_Plot_Version_1.tiff",res=300,width=8, height=8,units="in") print(p1 + RotatedAxis()) dev.off() p2 <- ggplot(temp7, aes(fill=Sample, y=NumberCells, x=Cluster)) + geom_bar(position="fill", stat="identity") + scale_fill_manual(values=hue_pal()(3)[c(1,2,3)]) + labs(y="Percent Total Bins") + theme(panel.background = element_rect(fill = "white",colour = "white")) + theme(panel.border = element_rect(colour = "black", fill=NA, size=0.5)) + geom_hline(yintercept=0, size=0.5)+ geom_hline(yintercept=0, size=0.5)+ geom_vline(xintercept=0, size=0.5) p2 tiff("Cluster_vs_Number_Bin_Bar_Plot_Version_2.tiff",res=300,width=8, height=8,units="in") print(p2 + RotatedAxis()) dev.off() write.table(temp7,"cluster_vs_sample_class_breakdown.txt",sep="\t") ######################### # Sample breakdown vs cluster ######################### running.stack <- NULL temp0 <- sort(unique(pbmc.merged@meta.data$seurat_clusters)) for (i in 1:length(temp0)) { print(i) temp1 <- pbmc.merged@meta.data$Sample[pbmc.merged@meta.data$seurat_clusters==temp0[i]] temp2 <- table(temp1) if(length(intersect(names(temp2),"AZ.109.146"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "AZ.109.146" } if(length(intersect(names(temp2),"AZ.251.146"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "AZ.251.146" } if(length(intersect(names(temp2),"AZ.84.145"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "AZ.84.145" } if(length(intersect(names(temp2),"AZ.90.242"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "AZ.90.242" } if(length(intersect(names(temp2),"AZ.99.140"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "AZ.99.140" } if(length(intersect(names(temp2),"Control.H190.260"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "Control.H190.260" } if(length(intersect(names(temp2),"Control.H250.185"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "Control.H250.185" } if(length(intersect(names(temp2),"Control.OFB57.194"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "Control.OFB57.194" } if(length(intersect(names(temp2),"Control.OFB6A.107"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "Control.OFB6A.107" } if(length(intersect(names(temp2),"PD.52.247"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "PD.52.247" } if(length(intersect(names(temp2),"PD.56.236"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "PD.56.236" } if(length(intersect(names(temp2),"PD.58.229"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "PD.58.229" } if(length(intersect(names(temp2),"PD.77.197"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "PD.77.197" } if(length(intersect(names(temp2),"PD.79.201"))==0) { temp2 <- c(temp2,0) names(temp2)[length(temp2)] <- "PD.79.201" } temp2 <- temp2[c("AZ.109.146","AZ.251.146","AZ.84.145","AZ.90.242","AZ.99.140","Control.H190.260","Control.H250.185","Control.OFB57.194","Control.OFB6A.107","PD.52.247","PD.56.236","PD.58.229","PD.77.197","PD.79.201")] running.stack <- rbind(running.stack,as.numeric(temp2)) } running.stack <- cbind(temp0,running.stack) dimnames(running.stack)[[2]] <- c("Cluster","AZ.109.146","AZ_251_146","AZ.84.145","AZ.90.242","AZ.99.140","Control.H190.260","Control.H250.185","Control.OFB57.194","Control.OFB6A.107","PD.52.247","PD.56.236","PD.58.229","PD.77.197","PD.79.201") running.stack <- as.data.frame(running.stack) running.stack$Cluster <- as.factor(running.stack$Cluster) temp3 <- c("AZ.1","AZ.2","AZ.3","AZ.4","AZ.5","Cntrl.1","Cntrl.2","Cntrl.3","Cntrl.4","PD.1","PD.2","PD.3","PD.4","PD.5") temp4 <- NULL for (i in 1:length(temp3)) { temp5 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep(temp3[i],dim(running.stack)[1]))),NumberCells=running.stack[,c(i+1)]) temp4 <- rbind(temp4,temp5) } p3 <- ggplot(temp4, aes(fill=Cluster, y=log2(NumberCells+2), x=Sample)) + geom_bar(position="stack", stat="identity") + scale_fill_manual(values=hue_pal()(length(temp0))) + labs(y="Log2(Number Bins + 2)") + theme(panel.background = element_rect(fill = "white",colour = "white")) + geom_hline(yintercept=0, size=0.5) p3 tiff("Bar_Plot_Version_3.tiff",res=300,width=8, height=8,units="in") p3 dev.off() p4 <- ggplot(temp4, aes(fill=Cluster, y=NumberCells, x=Sample)) + geom_bar(position="fill", stat="identity") + scale_fill_manual(values=hue_pal()(length(temp0))) + labs(y="Percent Total Bins") + theme(panel.background = element_rect(fill = "white",colour = "white")) + geom_hline(yintercept=0, size=0.5) + geom_hline(yintercept=1, size=0.5) + geom_hline(yintercept=0.5, size=0.25,linetype="dashed") + geom_hline(yintercept=0.25, size=0.25,linetype="dashed")+ geom_hline(yintercept=0.75, size=0.25,linetype="dashed") p4 tiff("Bar_Plot_Version_4.tiff",res=300,width=8, height=8,units="in") p4 dev.off() write.table(temp4,"temp4.txt",sep="\t") save.image("Current_20201006.RData") load.image("Current_20201006.RData") temp0 <- coded.ready.to.cluster temp0 <- coded.ready.to.cluster[,coded.ready.to.cluster[22,]>0] temp1 <- apply(temp0,2,paste,collapse="_",sep="_") temp2 <- rev(sort(table(temp1))) length(temp2) length(temp2[temp2>1]) length(temp2[temp2>2]) length(temp2[temp2>3]) length(temp2[temp2>4]) length(temp2[temp2>5]) length(temp2[temp2>6]) length(temp2[temp2>7]) length(temp2[temp2>8]) length(temp2[temp2>9]) length(temp2[temp2>10]) length(temp2[temp2>99]) length(temp2[temp2>500]) temp3 <- temp2[temp2>10] dimnames(coded.ready.to.cluster)[[1]] working <- CreateSeuratObject(counts = coded.ready.to.cluster) temp <- colnames(working) temptemp <- strsplit(temp,"_Pos_") temptemp <- as.data.frame(temptemp) temptemp <- t(temptemp) dimnames(temptemp)[[1]] <- temp temp <- as.character(temptemp[,2]) temp <- strsplit(temp,"X") temp <- as.data.frame(temp) temp <- t(temp) temptemp <- cbind(temptemp,temp) dimnames(temptemp)[[2]] <- c("Sample","PosCx","Xpos","Ypos") working@meta.data$Sample <- temptemp[,1] working@meta.data$PosCx <- temptemp[,2] working@meta.data$Xpos <- temptemp[,3] working@meta.data$Ypos <- temptemp[,4] temp <- temptemp[,1] temptemp <- strsplit(temp,"_") temptemp <- as.data.frame(temptemp) temptemp <- t(temptemp) working@meta.data$Type <- temptemp[,2] working <- SCTransform(working) working <- RunPCA(working,npcs=24) DimPlot(working,reduction="pca",label=FALSE) e <- ElbowPlot(working, ndims=24,reduction="pca") e dims2use <- 7 #tiff("Primary_Analysis_Elbow_Plot.tiff",res=300,width=8, height=8,units="in") pdf("Primary_Analysis_Elbow_Plot.pdf") plot(e[[1]],xlab="PC",ylab="SD",main="Elbow Plot",type='b') abline(v=dims2use,lwd=2,col=2,lty=2) dev.off() working <- FindNeighbors(working,dims=1:dims2use) working <- FindClusters(working) working <- RunUMAP(working,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Primary_Analysis_UMAP_Plot.tiff",res=300,width=8, height=8,units="in") pdf("Primary_Analysis_UMAP_Plot.pdf") DimPlot(working,reduction="umap",label=FALSE) + NoLegend() dev.off() DimPlot(working,reduction="umap",label=FALSE) DimPlot(working,reduction="umap",label=FALSE) + NoLegend() #tiff("Primary_Analysis_UMAP_Plot_2.tiff",res=300,width=8, height=8,units="in") #DimPlot(working,reduction="umap",group.by = "Sample") #dev.off() #tiff("Primary_Analysis_UMAP_Plot_3.tiff",res=300,width=8, height=8,units="in") #DimPlot(working,reduction="umap",group.by = "Type") #dev.off() #tiff("Primary_Analysis_UMAP_Plot_4.tiff",res=300,width=24, height=8,units="in") #DimPlot(working,reduction="umap",split.by="Type",group.by="Type") #dev.off() original.working <- working FeaturePlot(working,"TAU") DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() ############################################## # Output Sample vs Super Cluster Breakdown ############################################## temp1 <- working@meta.data$Sample temp2 <- working@meta.data$seurat_clusters temp3 <- cbind(temp1,temp2) temp4 <- apply(temp3,1,paste,collapse="_",sep="_") write.table(temp4,"Sample_vs_Cluster_Breakdown.txt",sep="\t") plot(sort(table((as.numeric(temp3[,2])-1))),ylab="Number Bins",xlab="Cluster",main="Tau (Total Bins = 2812)",type='b') ####################################### # Generate Slide Plots ####################################### full.bulb <- c("Final_Analysis_Ready_Counts_AZ_109_146", "Final_Analysis_Ready_Counts_AZ_251_146", "Final_Analysis_Ready_Counts_AZ_84_145", "Final_Analysis_Ready_Counts_AZ_90_242", "Final_Analysis_Ready_Counts_AZ_99_140", "Final_Analysis_Ready_Counts_Control_H190_260", "Final_Analysis_Ready_Counts_Control_H250_185", "Final_Analysis_Ready_Counts_Control_OFB57_194", "Final_Analysis_Ready_Counts_Control_OFB6A_107", "Final_Analysis_Ready_Counts_PD_52_247", "Final_Analysis_Ready_Counts_PD_56_236", "Final_Analysis_Ready_Counts_PD_58_229", "Final_Analysis_Ready_Counts_PD_77_197", "Final_Analysis_Ready_Counts_PD_79_201") unique.samples <- sort(unique(working@meta.data$Sample)) for(s in 1:length(unique.samples)) { print(s) # subset sample bin data new.x <- working@meta.data$Xpos[working@meta.data$Sample==unique.samples[s]] new.y <- working@meta.data$Ypos[working@meta.data$Sample==unique.samples[s]] new.clusters <- working@meta.data$seurat_clusters[working@meta.data$Sample==unique.samples[s]] my_color_palette <- hue_pal()(length(unique(working@meta.data$seurat_clusters))) col.2.use <- my_color_palette[as.numeric(as.character(working@meta.data$seurat_clusters))+1][working@meta.data$Sample==unique.samples[s]] b1 <- eval(parse(text=full.bulb[s])) b1 <- dimnames(b1)[[1]] b1 <- strsplit(b1,"X") b1 <- as.data.frame(b1) b1 <- t(b1) # generate all detected bins plot # temp <- paste(c(unique.samples[s],"_","All_Detected_Bins_Super_Clustering_Slide_Plot.tiff"),sep="",collapse="") # tiff(eval(temp),width = 28950, height = 6030, units = "px",res=300) temp <- paste(c(unique.samples[s],"_","All_Detected_Bins_Super_Clustering_Slide_Plot.pdf"),sep="",collapse="") pdf(eval(temp),width = 28950/1000, height = 6030/1000) plot(as.numeric(b1[,1]),-1*as.numeric(b1[,2]),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8, main="Whole Bulb") # dev.off() plot(c(1:length(my_color_palette)),c(1:length(my_color_palette)),col=my_color_palette,pch="-",cex=4,xlab="Label",ylab="Label",main="Color Legend") text(c(1:round(length(my_color_palette)/2))+.9,c(1:round(length(my_color_palette)/2)),as.character((c(1:round(length(my_color_palette)/2))-1)),col="black") text(c(round(length(my_color_palette)/2):(length(my_color_palette)-1))-.4,c((round(length(my_color_palette)/2)+1):length(my_color_palette)),as.character(c(round(length(my_color_palette)/2):(length(my_color_palette)-1))),col="black") # generate all detected bins all clusters plot # temp <- paste(c(unique.samples[s],"_","All_Detected_Bins_All_Clusters_Super_Clustering_Slide_Plot.tiff"),sep="",collapse="") #tiff(eval(temp),width = 28950, height = 6030, units = "px",res=300) plot(as.numeric(b1[,1]),-1*as.numeric(b1[,2]),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8, main="Detected Bins") points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use) # dev.off() # generate cluster plots for(c in 1:length(my_color_palette)) { # temp <- paste(c(unique.samples[s],"_Super_Clustering_",c-1,"_Slide_Plot.tiff"),sep="",collapse="") # tiff(eval(temp),width = 28950, height = 6030, units = "px",res=300) plot(as.numeric(b1[,1]),-1*as.numeric(b1[,2]),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8, main=as.character(c-1)) points(as.numeric(new.x[col.2.use==my_color_palette[c]]),-1*as.numeric((new.y[col.2.use==my_color_palette[c]])),col=col.2.use[col.2.use==my_color_palette[c]],cex=1,pch=15) # dev.off() } dev.off() } ####################################### # I/O ####################################### saveRDS(original.working,"original.working.rds") #original.working <- readRDS("original.working.rds") ####################################### # Perform Super Clustering ####################################### working <- original.working s.clusters <- as.numeric(working@meta.data$seurat_clusters) ccc <- GetAssayData(object=working,slot="counts") ccc <- as.matrix(ccc) ddd <- ifelse(ccc==0,NA,ccc) running.clusters <- unique(sort(s.clusters)) running.means <- NULL multi.mean <- 0 if (multi.mean==1) { temptemptemp <- NULL temp1 <- sort(table(s.clusters)) temp2 <- temp1/10000 temp3 <- ifelse(as.numeric(unlist(temp2))<1,1,temp2) names(temp3) <- names(temp2) temp3 <- round(temp3,0) replication.factor <- rev(temp3) for(i in 1:length(running.clusters)) { print(i) temp <- ddd[,s.clusters==running.clusters[i]] temptemp <- dim(temp)[2] temp <- apply(temp,1,mean,na.rm=T) temp <- ifelse(is.na(temp),0,temp) temp <- round(temp,0) rock.it <- as.numeric(unlist(replication.factor[as.character(running.clusters[i])])) for (j in 1:rock.it) { running.means <- cbind(running.means,temp) temptemptemp <- c(temptemptemp,running.clusters[i]) } } dimnames(running.means)[[2]] <- temptemptemp } if (multi.mean==0) { for(i in 1:length(running.clusters)) { print(i) temp <- ddd[,s.clusters==running.clusters[i]] temptemp <- dim(temp)[2] temp <- apply(temp,1,mean,na.rm=T) temp <- ifelse(is.na(temp),0,temp) temp <- round(temp,0) running.means <- cbind(running.means,temp) } dimnames(running.means)[[2]] <- running.clusters } www <- CreateSeuratObject(counts = running.means) www <- subset(www, subset = nCount_RNA > 0 & nFeature_RNA > 0) www@meta.data$Prior <- colnames(www) www <- SCTransform(www) www <- RunPCA(www,assay="SCT",npcs=25) saveRDS(www,"www.rds") ee <- ElbowPlot(www, ndims=25,reduction="pca") ee dims2use <- 5 #tiff("Super_Cluster_Elbow_Plot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_Elbow_Plot.pdf") plot(ee[[1]],xlab="PC",ylab="SD",main="Elbow Plot",type='b') abline(v=dims2use,lwd=2,col=2,lty=2) dev.off() www <- FindNeighbors(www,dims=1:dims2use,reduction="pca") www <- FindClusters(www,resolution=0.8) # Edit Here www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") pdf("Mean_Cluster_UMAP_Plot_Resolution_Default.pdf") # Edit Here DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters #tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_DotPlot_Resolution_Default.pdf") # Edit Here DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() www <- FindClusters(www,resolution=1) # Edit Here www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") pdf("Mean_Cluster_UMAP_Plot_Resolution_1.pdf") # Edit Here DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters #tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_DotPlot_Resolution_1.pdf") # Edit Here DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() www <- FindClusters(www,resolution=2) # Edit Here www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") pdf("Mean_Cluster_UMAP_Plot_Resolution_2.pdf") # Edit Here DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters #tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_DotPlot_Resolution_2.pdf") # Edit Here DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() www <- FindClusters(www,resolution=4) # Edit Here www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") pdf("Mean_Cluster_UMAP_Plot_Resolution_4.pdf") # Edit Here DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters #tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_DotPlot_Resolution_4.pdf") # Edit Here DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() www <- FindClusters(www,resolution=6) # Edit Here www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") pdf("Mean_Cluster_UMAP_Plot_Resolution_6.pdf") # Edit Here DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters #tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_DotPlot_Resolution_6.pdf") # Edit Here DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() www <- FindClusters(www,resolution=8) # Edit Here www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") pdf("Mean_Cluster_UMAP_Plot_Resolution_8.pdf") # Edit Here DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters #tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_DotPlot_Resolution_8.pdf") # Edit Here DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() www <- FindClusters(www,resolution=10) # Edit Here www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") pdf("Mean_Cluster_UMAP_Plot_Resolution_10.pdf") # Edit Here DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters #tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_DotPlot_Resolution_10.pdf") # Edit Here DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() www <- FindClusters(www,resolution=12) # Edit Here www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") pdf("Mean_Cluster_UMAP_Plot_Resolution_12.pdf") # Edit Here DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters #tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_DotPlot_Resolution_12.pdf") # Edit Here DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() www <- FindClusters(www,resolution=14) # Edit Here www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") pdf("Mean_Cluster_UMAP_Plot_Resolution_14.pdf") # Edit Here DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters #tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_DotPlot_Resolution_14.pdf") # Edit Here DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() www <- FindClusters(www,resolution=16) # Edit Here www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") pdf("Mean_Cluster_UMAP_Plot_Resolution_16.pdf") # Edit Here DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters #tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_DotPlot_Resolution_16.pdf") # Edit Here DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() www <- FindClusters(www,resolution=18) # Edit Here www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") pdf("Mean_Cluster_UMAP_Plot_Resolution_18.pdf") # Edit Here DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters #tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_DotPlot_Resolution_18.pdf") # Edit Here DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() www <- FindClusters(www,resolution=20) # Edit Here www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") pdf("Mean_Cluster_UMAP_Plot_Resolution_20.pdf") # Edit Here DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters #tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_DotPlot_Resolution_20.pdf") # Edit Here DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() www <- FindClusters(www,resolution=25) # Edit Here www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) #tiff("Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") pdf("Mean_Cluster_UMAP_Plot_Resolution_40.pdf") # Edit Here DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters #tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") pdf("Super_Cluster_DotPlot_Resolution_40.pdf") # Edit Here DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() ############################################## # Output Sample vs Super Cluster Breakdown ############################################## temp1 <- working@meta.data$Sample temp2 <- working@meta.data$seurat_clusters temp3 <- cbind(temp1,temp2) temp4 <- apply(temp3,1,paste,collapse="_",sep="_") write.table(temp4,"Sample_vs_Super_Cluster_Breakdown.txt",sep="\t") ####################################### # Generate Slide Plots ####################################### full.bulb <- c("Final_Analysis_Ready_Counts_AZ_109_146", "Final_Analysis_Ready_Counts_AZ_251_146", "Final_Analysis_Ready_Counts_AZ_84_145", "Final_Analysis_Ready_Counts_AZ_90_242", "Final_Analysis_Ready_Counts_AZ_99_140", "Final_Analysis_Ready_Counts_Control_H190_260", "Final_Analysis_Ready_Counts_Control_H250_185", "Final_Analysis_Ready_Counts_Control_OFB57_194", "Final_Analysis_Ready_Counts_Control_OFB6A_107", "Final_Analysis_Ready_Counts_PD_52_247", "Final_Analysis_Ready_Counts_PD_56_236", "Final_Analysis_Ready_Counts_PD_58_229", "Final_Analysis_Ready_Counts_PD_77_197", "Final_Analysis_Ready_Counts_PD_79_201") unique.samples <- sort(unique(working@meta.data$Sample)) for(s in 1:length(unique.samples)) { print(s) # subset sample bin data new.x <- working@meta.data$Xpos[working@meta.data$Sample==unique.samples[s]] new.y <- working@meta.data$Ypos[working@meta.data$Sample==unique.samples[s]] new.clusters <- working@meta.data$seurat_clusters[working@meta.data$Sample==unique.samples[s]] my_color_palette <- hue_pal()(length(unique(working@meta.data$seurat_clusters))) col.2.use <- my_color_palette[as.numeric(as.character(working@meta.data$seurat_clusters))+1][working@meta.data$Sample==unique.samples[s]] b1 <- eval(parse(text=full.bulb[s])) b1 <- dimnames(b1)[[1]] b1 <- strsplit(b1,"X") b1 <- as.data.frame(b1) b1 <- t(b1) # generate all detected bins plot # temp <- paste(c(unique.samples[s],"_","All_Detected_Bins_Super_Clustering_Slide_Plot.tiff"),sep="",collapse="") # tiff(eval(temp),width = 28950, height = 6030, units = "px",res=300) temp <- paste(c(unique.samples[s],"_","All_Detected_Bins_Super_Clustering_Slide_Plot.pdf"),sep="",collapse="") pdf(eval(temp),width = 28950/1000, height = 6030/1000) plot(as.numeric(b1[,1]),-1*as.numeric(b1[,2]),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8, main="Whole Bulb") # dev.off() plot(c(1:27),c(1:27),col=my_color_palette,pch="-",cex=4,xlab="Label",ylab="Label",main="Color Legend") text(c(1:13)+.5,c(1:13),as.character(c(0:12)),col="black") text(c(14:27)-.5,c(14:27),as.character(c(13:26)),col="black") # generate all detected bins all clusters plot # temp <- paste(c(unique.samples[s],"_","All_Detected_Bins_All_Clusters_Super_Clustering_Slide_Plot.tiff"),sep="",collapse="") #tiff(eval(temp),width = 28950, height = 6030, units = "px",res=300) plot(as.numeric(b1[,1]),-1*as.numeric(b1[,2]),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8, main="Detected Bins") points(as.numeric(new.x),-1*as.numeric(new.y),cex=1,pch=15,col=col.2.use) # dev.off() # generate cluster plots for(c in 1:length(my_color_palette)) { # temp <- paste(c(unique.samples[s],"_Super_Clustering_",c-1,"_Slide_Plot.tiff"),sep="",collapse="") # tiff(eval(temp),width = 28950, height = 6030, units = "px",res=300) plot(as.numeric(b1[,1]),-1*as.numeric(b1[,2]),cex=1,pch=15,axes=FALSE,xlab="",ylab="",col=8, main=as.character(c-1)) points(as.numeric(new.x[col.2.use==my_color_palette[c]]),-1*as.numeric((new.y[col.2.use==my_color_palette[c]])),col=col.2.use[col.2.use==my_color_palette[c]],cex=1,pch=15) # dev.off() } dev.off() } ############################################## # Generate Violin Plots per Label vs Cluster ############################################## tiff("Violin_Plot_ALPHA_SYNUCLEIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[1],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_BETA_AMYLOID_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[2],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_CALBINDIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[3],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_CD31_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[4],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_CH_NEUN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[5],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_CNPASE_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[6],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_COLLAGEN_IV_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[7],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_DAPI_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[8],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_GFAP_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[9],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_HISTONES_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[10],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_HLADR_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[11],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_IBA1_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[12],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_MAP2_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[13],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_MBP_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[14],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_NEURO_HEAVY_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[15],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_NEURO_LIGHT_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[16],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_OMP_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[17],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_PGP9_5_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[18],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_RB_CALRETININ_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[19],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_S100_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[20],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_SYNAPTOPHYSIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[21],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_TAU_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[22],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_TOMATO_LECTIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[23],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_TYR_HYDROXYLASE_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[24],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Violin_Plot_UEA_LECTIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[25],group.by="seurat_clusters",pt.size=0) dev.off() # Special tiff("Violin_Plot_TAU_vs_Cluster_vs_Type.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[22],group.by="seurat_clusters",pt.size=0,split.by="Type",col=hue_pal()(3)) dev.off() ############################################## # Generate Ridge Plots per Label vs Cluster ############################################## tiff("Ridge_Plot_ALPHA_SYNUCLEIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[1],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_BETA_AMYLOID_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[2],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_CALBINDIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[3],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_CD31_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[4],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_CH_NEUN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[5],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_CNPASE_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[6],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_COLLAGEN_IV_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[7],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_DAPI_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[8],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_GFAP_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[9],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_HISTONES_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[10],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_HLADR_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[11],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_IBA1_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[12],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_MAP2_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[13],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_MBP_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[14],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_NEURO_HEAVY_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[15],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_NEURO_LIGHT_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[16],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_OMP_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[17],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_PGP9_5_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[18],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_RB_CALRETININ_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[19],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_S100_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[20],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_SYNAPTOPHYSIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[21],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_TAU_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[22],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_TOMATO_LECTIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[23],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_TYR_HYDROXYLASE_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[24],group.by="seurat_clusters") dev.off() tiff("Ridge_Plot_UEA_LECTIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[25],group.by="seurat_clusters") dev.off() ############################################## # Generate Feature Plots per Label vs Cluster ############################################## tiff("UMAP_Plot_ALPHA_SYNUCLEIN_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[1]) dev.off() tiff("UMAP_Plot_BETA_AMYLOID_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[2]) dev.off() tiff("UMAP_Plot_CALBINDIN_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[3]) dev.off() tiff("UMAP_Plot_CD31_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[4]) dev.off() tiff("UMAP_Plot_CH_NEUN_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[5]) dev.off() tiff("UMAP_Plot_CNPASE_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[6]) dev.off() tiff("UMAP_Plot_COLLAGEN_IV_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[7]) dev.off() tiff("UMAP_Plot_DAPI_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[8]) dev.off() tiff("UMAP_Plot_GFAP_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[9]) dev.off() tiff("UMAP_Plot_HISTONES_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[10]) dev.off() tiff("UMAP_Plot_HLADR_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[11]) dev.off() tiff("UMAP_Plot_IBA1_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[12]) dev.off() tiff("UMAP_Plot_MAP2_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[13]) dev.off() tiff("UMAP_Plot_MBP_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[14]) dev.off() tiff("UMAP_Plot_NEURO_HEAVY_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[15]) dev.off() tiff("UMAP_Plot_NEURO_LIGHT_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[16]) dev.off() tiff("UMAP_Plot_OMP_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[17]) dev.off() tiff("UMAP_Plot_PGP9_5_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[18]) dev.off() tiff("UMAP_Plot_RB_CALRETININ_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[19]) dev.off() tiff("UMAP_Plot_S100_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[20]) dev.off() tiff("UMAP_Plot_SYNAPTOPHYSIN_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[21]) dev.off() tiff("UMAP_Plot_TAU_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[22]) dev.off() tiff("UMAP_Plot_TOMATO_LECTIN_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[23]) dev.off() tiff("UMAP_Plot_TYR_HYDROXYLASE_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[24]) dev.off() tiff("UMAP_Plot_UEA_LECTIN_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[25]) dev.off() tiff("UMAP_Plot_TAU_vs_Cluster_vs_Type.tiff",width = 24, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[22],split.by="Type") dev.off() ############################################## # Stacked BarChart # https://protect-au.mimecast.com/s/gm_LC2xMp1UZlYQvuZPKBD?domain=r-graph-gallery.com ############################################## library(ggplot2) library(viridis) running.stack <- NULL temp0 <- sort(unique(working@meta.data$super.clusters)) for (i in 1:length(temp0)) { print(i) temp1 <- working@meta.data$Type[working@meta.data$super.clusters==temp0[i]] temp2 <- table(temp1) temp2 <- temp2[c("Control","AZ","PD")] running.stack <- rbind(running.stack,as.numeric(temp2)) } running.stack <- cbind(temp0,running.stack) dimnames(running.stack)[[2]] <- c("Cluster","Control","AZ","PD") running.stack <- as.data.frame(running.stack) running.stack$Cluster <- as.factor(running.stack$Cluster) temp3 <- running.stack[,c(1,2)] temp3 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep("Control",dim(running.stack)[1]))),NumberCells=running.stack[,c(2)]) temp4 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep("AZ",dim(running.stack)[1]))),NumberCells=running.stack[,c(3)]) temp5 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep("PD",dim(running.stack)[1]))),NumberCells=running.stack[,c(4)]) temp6 <- rbind(temp4,temp3,temp5) temp7 <- temp6[order(temp6$Cluster), ] p1 <- ggplot(temp7, aes(fill=Sample, y=log2(NumberCells+2), x=Cluster)) + geom_bar(position="stack", stat="identity") + scale_fill_manual(values=hue_pal()(3)[c(1,2,3)]) + labs(y="Log2(Number Bins + 2)") + theme(panel.background = element_rect(fill = "white",colour = "white")) + geom_hline(yintercept=0, size=0.5) p1 tiff("Bar_Plot_Version_1.tiff",res=300,width=8, height=8,units="in") p1 dev.off() p2 <- ggplot(temp7, aes(fill=Sample, y=NumberCells, x=Cluster)) + geom_bar(position="fill", stat="identity") + scale_fill_manual(values=hue_pal()(3)[c(1,2,3)]) + labs(y="Percent Total Bins") + theme(panel.background = element_rect(fill = "white",colour = "white")) + theme(panel.border = element_rect(colour = "black", fill=NA, size=0.5)) + geom_hline(yintercept=0, size=0.5)+ geom_hline(yintercept=0, size=0.5)+ geom_vline(xintercept=0, size=0.5) p2 tiff("Bar_Plot_Version_2.tiff",res=300,width=8, height=8,units="in") p2 dev.off() write.table(temp7,"cluster_vs_sample_class_breakdown.txt",sep="\t") ######################### # Sample breakdown vs cluster ######################### running.stack <- NULL temp0 <- sort(unique(working@meta.data$seurat_clusters)) for (i in 1:length(temp0)) { print(i) temp1 <- working@meta.data$Sample[working@meta.data$seurat_clusters==temp0[i]] temp2 <- table(temp1) temp2 <- temp2[c("AZ_109_146","AZ_251_146","AZ_84_145","AZ_90_242","AZ_99_140","Control_H190_260","Control_H246_174","Control_H250_185","Control_OFB57_194","Control_OFB6A_107","PD_52_247","PD_56_236","PD_58_229","PD_77_197","PD_79_201")] temp2 <- as.numeric(temp2) temp2 <- ifelse(is.na(temp2),0,temp2) running.stack <- rbind(running.stack,as.numeric(temp2)) } running.stack <- cbind(temp0,running.stack) dimnames(running.stack)[[2]] <- c("Cluster","AZ_109_146","AZ_251_146","AZ_84_145","AZ_90_242","AZ_99_140","Control_H190_260","Control_H246_174","Control_H250_185","Control_OFB57_194","Control_OFB6A_107","PD_52_247","PD_56_236","PD_58_229","PD_77_197","PD_79_201") running.stack <- as.data.frame(running.stack) running.stack$Cluster <- as.factor(running.stack$Cluster) temp3 <- c("AZ.1","AZ.2","AZ.3","AZ.4","AZ.5","Cntrl.1","Cntrl.2","Cntrl.3","Cntrl.4","Cntrl.5","PD.1","PD.2","PD.3","PD.4","PD.5") temp4 <- NULL for (i in 1:length(temp3)) { temp5 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep(temp3[i],dim(running.stack)[1]))),NumberCells=running.stack[,c(i+1)]) temp4 <- rbind(temp4,temp5) } p3 <- ggplot(temp4, aes(fill=Cluster, y=log2(NumberCells+2), x=Sample)) + geom_bar(position="stack", stat="identity") + scale_fill_manual(values=hue_pal()(length(temp0))) + labs(y="Log2(Number Bins + 2)") + theme(panel.background = element_rect(fill = "white",colour = "white")) + geom_hline(yintercept=0, size=0.5) tiff("Bar_Plot_Version_3.tiff",res=300,width=8, height=8,units="in") p3 dev.off() p4 <- ggplot(temp4, aes(fill=Cluster, y=NumberCells, x=Sample)) + geom_bar(position="fill", stat="identity") + scale_fill_manual(values=hue_pal()(length(temp0))) + labs(y="Percent Total Bins") + theme(panel.background = element_rect(fill = "white",colour = "white")) + geom_hline(yintercept=0, size=0.5) + geom_hline(yintercept=1, size=0.5) + geom_hline(yintercept=0.5, size=0.25,linetype="dashed") + geom_hline(yintercept=0.25, size=0.25,linetype="dashed")+ geom_hline(yintercept=0.75, size=0.25,linetype="dashed") p4 tiff("Bar_Plot_Version_4.tiff",res=300,width=8, height=8,units="in") p4 dev.off() ########################################### # Stacked Violin Plot # https://protect-au.mimecast.com/s/3oc1C3QNqKI9AkvwhRw2Eu?domain=divingintogeneticsandgenomics.rbind.io # https://protect-au.mimecast.com/s/QczfC4QOrYI90Vxyhywan6?domain=github.com ########################################### library(patchwork) modify_vlnplot<- function(obj, feature, pt.size = 0, plot.margin = unit(c(-0.75, 0, -0.75, 0), "cm"), ...) { p<- VlnPlot(obj, features = feature, pt.size = pt.size, ... ) + xlab("") + ylab(feature) + ggtitle("") + theme(legend.position = "none", axis.text.x = element_blank(), axis.ticks.x = element_blank(), axis.title.y = element_text(size = rel(1), angle = 0), axis.text.y = element_text(size = rel(1)), plot.margin = plot.margin ) return(p) } extract_max<- function(p){ ymax<- max(ggplot_build(p)$layout$panel_scales_y[[1]]$range$range) return(ceiling(ymax)) } StackedVlnPlot<- function(obj, features, pt.size = 0, plot.margin = unit(c(-0.75, 0, -0.75, 0), "cm"), ...) { plot_list<- purrr::map(features, function(x) modify_vlnplot(obj = obj,feature = x, ...)) # Add back x-axis title to bottom plot. patchwork is going to support this? plot_list[[length(plot_list)]]<- plot_list[[length(plot_list)]] + theme(axis.text.x=element_text(), axis.ticks.x = element_line()) # change the y-axis tick to only max value ymaxs<- purrr::map_dbl(plot_list, extract_max) plot_list<- purrr::map2(plot_list, ymaxs, function(x,y) x + scale_y_continuous(breaks = c(y)) + expand_limits(y = y)) p<- patchwork::wrap_plots(plotlist = plot_list, ncol = 1) return(p) } working2 <- working working2@meta.data$seurat_clusters <- factor(working2@meta.data$seurat_clusters, levels = as.character(c(0:20))) levels(working2@meta.data$seurat_clusters) tiff("Stacked_Violin_Plot.tiff",res=300,width=12, height=12,units="in") StackedVlnPlot(working2, features=rownames(working),group.by="seurat_clusters") dev.off() ############################################## # Copy output objects to Windows FileShare ############################################## scp -vr *.tiff johnsonko@nindsdirbis7.ninds.nih.gov:/shares/PI/Alan_Koretsky/Helen_Murray/Spatial_Transcriptomics/20200508 ####################################### # I/O ####################################### saveRDS(working,"final.working.rds") original.working <- readRDS("original.working.rds") final.working <- readRDS("final.working.rds") ####################################### ####################################### ####################################### ####################################### ####################################### # Subset out cluster Zero ####################################### ####################################### ####################################### ####################################### ####################################### ############################################## # Generate Dot Plot ############################################## tiff("Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() ############################################## # Remove Cluster Zero ############################################## zeroless <- subset(working, subset = seurat_clusters != 0) zero.only <- subset(working, subset = seurat_clusters == 0) ############################################################# # Perform Clustering ############################################################# zero.only <- SCTransform(zero.only) zero.only <- RunPCA(zero.only,assay="SCT",npcs=25) e <- ElbowPlot(zero.only, ndims=24,reduction="pca") sd.cut.2.use <- 2 dims2use <- sum(e[[1]][,2]>sd.cut.2.use) tiff("Zero_Cluster_Only_Primary_Analysis_Elbow_Plot.tiff",res=300,width=8, height=8,units="in") plot(e[[1]],xlab="PC",ylab="SD",main="Elbow Plot",type='b') abline(h=sd.cut.2.use,lwd=2,col=2,lty=2) abline(v=dims2use,lwd=2,col=2,lty=2) dev.off() zero.only <- FindNeighbors(zero.only,dims=1:dims2use,reduction="pca") zero.only <- FindClusters(zero.only) zero.only <- RunUMAP(zero.only,dims=1:dims2use,reduction="pca",do.return=TRUE) tiff("Zero_Cluster_Only_Primary_Analysis_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") DimPlot(zero.only,reduction="umap",label=FALSE) + NoLegend() dev.off() tiff("Zero_Cluster_Only_Primary_Analysis_UMAP_Plot_2.tiff",res=300,width=8, height=8,units="in") DimPlot(zero.only,reduction="umap",group.by = "Sample") dev.off() tiff("Zero_Cluster_Only_Primary_Analysis_UMAP_Plot_3.tiff",res=300,width=8, height=8,units="in") DimPlot(zero.only,reduction="umap",group.by = "Type") dev.off() tiff("Zero_Cluster_Only_Primary_Analysis_UMAP_Plot_4.tiff",res=300,width=24, height=8,units="in") DimPlot(zero.only,reduction="umap",split.by="Type",group.by="Type") dev.off() original.zero.only <- zero.only saveRDS(original.zero.only,"original.zero.only.rds") ####################################### # Perform Super Clustering ####################################### working <- original.zero.only s.clusters <- as.numeric(working@meta.data$seurat_clusters) ccc <- GetAssayData(object=working,slot="counts") ccc <- as.matrix(ccc) ddd <- ifelse(ccc==0,NA,ccc) running.clusters <- unique(sort(s.clusters)) running.means <- NULL multi.mean <- 0 if (multi.mean==1) { temptemptemp <- NULL temp1 <- sort(table(s.clusters)) temp2 <- temp1/10000 temp3 <- ifelse(as.numeric(unlist(temp2))<1,1,temp2) names(temp3) <- names(temp2) temp3 <- round(temp3,0) replication.factor <- rev(temp3) for(i in 1:length(running.clusters)) { print(i) temp <- ddd[,s.clusters==running.clusters[i]] temptemp <- dim(temp)[2] temp <- apply(temp,1,mean,na.rm=T) temp <- ifelse(is.na(temp),0,temp) temp <- round(temp,0) rock.it <- as.numeric(unlist(replication.factor[as.character(running.clusters[i])])) for (j in 1:rock.it) { running.means <- cbind(running.means,temp) temptemptemp <- c(temptemptemp,running.clusters[i]) } } dimnames(running.means)[[2]] <- temptemptemp } if (multi.mean==0) { for(i in 1:length(running.clusters)) { print(i) temp <- ddd[,s.clusters==running.clusters[i]] temptemp <- dim(temp)[2] temp <- apply(temp,1,mean,na.rm=T) temp <- ifelse(is.na(temp),0,temp) temp <- round(temp,0) running.means <- cbind(running.means,temp) } dimnames(running.means)[[2]] <- running.clusters } www <- CreateSeuratObject(counts = running.means) www <- subset(www, subset = nCount_RNA > 0 & nFeature_RNA > 0) www@meta.data$Prior <- colnames(www) www <- SCTransform(www) www <- RunPCA(www,assay="SCT",npcs=25) e <- ElbowPlot(www, ndims=24,reduction="pca") sd.cut.2.use <- 1 dims2use <- sum(e[[1]][,2]>sd.cut.2.use) tiff("Zero_Cluster_Only_Super_Cluster_Elbow_Plot.tiff",res=300,width=8, height=8,units="in") plot(e[[1]],xlab="PC",ylab="SD",main="Elbow Plot",type='b') abline(h=sd.cut.2.use,lwd=2,col=2,lty=2) abline(v=dims2use,lwd=2,col=2,lty=2) dev.off() www <- FindNeighbors(www,dims=1:dims2use,reduction="pca") www <- FindClusters(www,resolution = 2) # <====== Can Edit Here !!!!!!! #www <- FindClusters(www) www <- RunUMAP(www,dims=1:dims2use,reduction="pca",do.return=TRUE) tiff("Zero_Cluster_Only_Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") DimPlot(www,reduction="umap",label=TRUE) dev.off() super.clusters <- www@meta.data$seurat_clusters working@meta.data$super.clusters <- rep(0,length(colnames(working))) for (i in 1:length(super.clusters)) { working@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } working@meta.data$super.clusters <- working@meta.data$super.clusters-1 working@meta.data$all.clusters <- working@meta.data$seurat_clusters working@meta.data$seurat_clusters <- working@meta.data$super.clusters tiff("Zero_Cluster_Only_Super_Cluster_UMAP_Plot_2.tiff",res=300,width=8, height=8,units="in") DimPlot(working,reduction="umap",group.by="seurat_clusters",label=TRUE) dev.off() tiff("Zero_Cluster_Only_Super_Cluster_UMAP_Plot_3.tiff",res=300,width=24, height=8,units="in") DimPlot(working,reduction="umap",split.by="Type",group.by="seurat_clusters",label=TRUE) dev.off() tiff("Zero_Cluster_Only_Super_Cluster_UMAP_Plot_4.tiff",res=300,width=40, height=24,units="in") DimPlot(working,reduction="umap",split.by="Sample",group.by="seurat_clusters",label=TRUE,ncol=5) dev.off() ############################################## # Output Sample vs Super Cluster Breakdown ############################################## temp1 <- working@meta.data$Sample temp2 <- working@meta.data$seurat_clusters temp3 <- cbind(temp1,temp2) temp4 <- apply(temp3,1,paste,collapse="_",sep="_") write.table(temp4,"Zero_Cluster_Only_Sample_vs_Super_Cluster_Breakdown.txt",sep="\t") ############################################## # Generate Dot Plot ############################################## tiff("Zero_Cluster_Only_Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") DotPlot(working, features = row.names(working),group.by="seurat_clusters") + RotatedAxis() dev.off() ####################################### # Generate Slide Plots ####################################### unique.samples <- sort(unique(working@meta.data$Sample)) for(s in 1:length(unique.samples)) { print(s) # subset sample bin data new.x <- working@meta.data$Xpos[working@meta.data$Sample==unique.samples[s]] new.y <- working@meta.data$Ypos[working@meta.data$Sample==unique.samples[s]] new.clusters <- working@meta.data$seurat_clusters[working@meta.data$Sample==unique.samples[s]] my_color_palette <- hue_pal()(length(unique(working@meta.data$seurat_clusters))) col.2.use <- my_color_palette[as.numeric(as.character(working@meta.data$seurat_clusters))+1][working@meta.data$Sample==unique.samples[s]] # generate all detected bins plot temp <- paste(c(unique.samples[s],"_","Zero_Cluster_Only_All_Detected_Bins_Super_Clustering_Slide_Plot.tiff"),sep="",collapse="") tiff(eval(temp),width = 28950, height = 6030, units = "px",res=300) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=sqrt(31),pch=15,axes=FALSE,xlab="",ylab="",col=8) dev.off() # generate all detected bins all clusters plot temp <- paste(c(unique.samples[s],"_","Zero_Cluster_Only_All_Detected_Bins_All_Clusters_Super_Clustering_Slide_Plot.tiff"),sep="",collapse="") tiff(eval(temp),width = 28950, height = 6030, units = "px",res=300) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=sqrt(31),pch=15,axes=FALSE,xlab="",ylab="",col=col.2.use) dev.off() # generate cluster plots for(c in 1:length(my_color_palette)) { temp <- paste(c(unique.samples[s],"_Zero_Cluster_Only_Super_Clustering_",c-1,"_Slide_Plot.tiff"),sep="",collapse="") tiff(eval(temp),width = 28950, height = 6030, units = "px",res=300) plot(as.numeric(new.x),-1*as.numeric(new.y),col=8,pch=15,cex=sqrt(31),axes=FALSE,xlab="",ylab="") points(as.numeric(new.x[col.2.use==my_color_palette[c]]),-1*as.numeric((new.y[col.2.use==my_color_palette[c]])),col=col.2.use[col.2.use==my_color_palette[c]],cex=sqrt(31),pch=15) dev.off() } } ############################################## # Generate Violin Plots per Label vs Cluster ############################################## tiff("Zero_Cluster_Only_Violin_Plot_ALPHA_SYNUCLEIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[1],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_BETA_AMYLOID_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[2],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_CALBINDIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[3],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_CD31_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[4],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_CH_NEUN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[5],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_CNPASE_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[6],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_COLLAGEN_IV_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[7],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_DAPI_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[8],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_GFAP_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[9],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_HISTONES_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[10],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_HLADR_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[11],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_IBA1_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[12],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_MAP2_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[13],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_MBP_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[14],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_NEURO_HEAVY_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[15],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_NEURO_LIGHT_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[16],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_OMP_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[17],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_PGP9_5_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[18],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_RB_CALRETININ_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[19],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_S100_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[20],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_SYNAPTOPHYSIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[21],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_TAU_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[22],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_TOMATO_LECTIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[23],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_TYR_HYDROXYLASE_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[24],group.by="seurat_clusters",pt.size=0) dev.off() tiff("Zero_Cluster_Only_Violin_Plot_UEA_LECTIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[25],group.by="seurat_clusters",pt.size=0) dev.off() # Special tiff("Zero_Cluster_Only_Violin_Plot_TAU_vs_Cluster_vs_Type.tiff",width = 12, height = 8, units = "in",res=300) VlnPlot(working, features = rownames(working)[22],group.by="seurat_clusters",pt.size=0,split.by="Type",col=hue_pal()(3)) dev.off() ############################################## # Generate Ridge Plots per Label vs Cluster ############################################## tiff("Zero_Cluster_Only_Ridge_Plot_ALPHA_SYNUCLEIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[1],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_BETA_AMYLOID_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[2],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_CALBINDIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[3],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_CD31_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[4],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_CH_NEUN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[5],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_CNPASE_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[6],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_COLLAGEN_IV_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[7],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_DAPI_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[8],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_GFAP_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[9],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_HISTONES_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[10],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_HLADR_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[11],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_IBA1_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[12],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_MAP2_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[13],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_MBP_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[14],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_NEURO_HEAVY_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[15],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_NEURO_LIGHT_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[16],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_OMP_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[17],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_PGP9_5_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[18],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_RB_CALRETININ_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[19],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_S100_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[20],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_SYNAPTOPHYSIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[21],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_TAU_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[22],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_TOMATO_LECTIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[23],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_TYR_HYDROXYLASE_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[24],group.by="seurat_clusters") dev.off() tiff("Zero_Cluster_Only_Ridge_Plot_UEA_LECTIN_vs_Cluster.tiff",width = 12, height = 8, units = "in",res=300) RidgePlot(working, features = rownames(working)[25],group.by="seurat_clusters") dev.off() ############################################## # Generate Feature Plots per Label vs Cluster ############################################## tiff("Zero_Cluster_Only_UMAP_Plot_ALPHA_SYNUCLEIN_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[1]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_BETA_AMYLOID_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[2]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_CALBINDIN_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[3]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_CD31_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[4]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_CH_NEUN_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[5]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_CNPASE_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[6]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_COLLAGEN_IV_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[7]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_DAPI_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[8]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_GFAP_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[9]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_HISTONES_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[10]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_HLADR_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[11]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_IBA1_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[12]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_MAP2_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[13]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_MBP_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[14]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_NEURO_HEAVY_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[15]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_NEURO_LIGHT_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[16]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_OMP_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[17]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_PGP9_5_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[18]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_RB_CALRETININ_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[19]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_S100_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[20]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_SYNAPTOPHYSIN_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[21]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_TAU_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[22]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_TOMATO_LECTIN_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[23]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_TYR_HYDROXYLASE_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[24]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_UEA_LECTIN_vs_Cluster.tiff",width = 8, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[25]) dev.off() tiff("Zero_Cluster_Only_UMAP_Plot_TAU_vs_Cluster_vs_Type.tiff",width = 24, height = 8, units = "in",res=300) FeaturePlot(working, features = rownames(working)[22],split.by="Type") dev.off() ############################################## # Stacked BarChart # https://protect-au.mimecast.com/s/gm_LC2xMp1UZlYQvuZPKBD?domain=r-graph-gallery.com ############################################## library(ggplot2) library(viridis) running.stack <- NULL temp0 <- sort(unique(working@meta.data$super.clusters)) for (i in 1:length(temp0)) { print(i) temp1 <- working@meta.data$Type[working@meta.data$super.clusters==temp0[i]] temp2 <- table(temp1) temp2 <- temp2[c("Control","AZ","PD")] running.stack <- rbind(running.stack,as.numeric(temp2)) } running.stack <- cbind(temp0,running.stack) dimnames(running.stack)[[2]] <- c("Cluster","Control","AZ","PD") running.stack <- as.data.frame(running.stack) running.stack$Cluster <- as.factor(running.stack$Cluster) temp3 <- running.stack[,c(1,2)] temp3 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep("Control",dim(running.stack)[1]))),NumberCells=running.stack[,c(2)]) temp4 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep("AZ",dim(running.stack)[1]))),NumberCells=running.stack[,c(3)]) temp5 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep("PD",dim(running.stack)[1]))),NumberCells=running.stack[,c(4)]) temp6 <- rbind(temp4,temp3,temp5) temp7 <- temp6[order(temp6$Cluster), ] p1 <- ggplot(temp7, aes(fill=Sample, y=log2(NumberCells+2), x=Cluster)) + geom_bar(position="stack", stat="identity") + scale_fill_manual(values=hue_pal()(3)[c(1,2,3)]) + labs(y="Log2(Number Bins + 2)") + theme(panel.background = element_rect(fill = "white",colour = "white")) + geom_hline(yintercept=0, size=0.5) p1 tiff("Zero_Cluster_Only_Bar_Plot_Version_1.tiff",res=300,width=8, height=8,units="in") p1 dev.off() p2 <- ggplot(temp7, aes(fill=Sample, y=NumberCells, x=Cluster)) + geom_bar(position="fill", stat="identity") + scale_fill_manual(values=hue_pal()(3)[c(1,2,3)]) + labs(y="Percent Total Bins") + theme(panel.background = element_rect(fill = "white",colour = "white")) + theme(panel.border = element_rect(colour = "black", fill=NA, size=0.5)) + geom_hline(yintercept=0, size=0.5)+ geom_hline(yintercept=0, size=0.5)+ geom_vline(xintercept=0, size=0.5) p2 tiff("Zero_Cluster_Only_Bar_Plot_Version_2.tiff",res=300,width=8, height=8,units="in") p2 dev.off() write.table(temp7,"Zero_Cluster_Only_cluster_vs_sample_class_breakdown.txt",sep="\t") ######################### # Sample breakdown vs cluster ######################### running.stack <- NULL temp0 <- sort(unique(working@meta.data$seurat_clusters)) for (i in 1:length(temp0)) { print(i) temp1 <- working@meta.data$Sample[working@meta.data$seurat_clusters==temp0[i]] temp2 <- table(temp1) temp2 <- temp2[c("AZ_109_146","AZ_251_146","AZ_84_145","AZ_90_242","AZ_99_140","Control_H190_260","Control_H246_174","Control_H250_185","Control_OFB57_194","Control_OFB6A_107","PD_52_247","PD_56_236","PD_58_229","PD_77_197","PD_79_201")] temp2 <- as.numeric(temp2) temp2 <- ifelse(is.na(temp2),0,temp2) running.stack <- rbind(running.stack,as.numeric(temp2)) } running.stack <- cbind(temp0,running.stack) dimnames(running.stack)[[2]] <- c("Cluster","AZ_109_146","AZ_251_146","AZ_84_145","AZ_90_242","AZ_99_140","Control_H190_260","Control_H246_174","Control_H250_185","Control_OFB57_194","Control_OFB6A_107","PD_52_247","PD_56_236","PD_58_229","PD_77_197","PD_79_201") running.stack <- as.data.frame(running.stack) running.stack$Cluster <- as.factor(running.stack$Cluster) temp3 <- c("AZ.1","AZ.2","AZ.3","AZ.4","AZ.5","Cntrl.1","Cntrl.2","Cntrl.3","Cntrl.4","Cntrl.5","PD.1","PD.2","PD.3","PD.4","PD.5") temp4 <- NULL for (i in 1:length(temp3)) { temp5 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep(temp3[i],dim(running.stack)[1]))),NumberCells=running.stack[,c(i+1)]) temp4 <- rbind(temp4,temp5) } p3 <- ggplot(temp4, aes(fill=Cluster, y=log2(NumberCells+2), x=Sample)) + geom_bar(position="stack", stat="identity") + scale_fill_manual(values=hue_pal()(length(temp0))) + labs(y="Log2(Number Bins + 2)") + theme(panel.background = element_rect(fill = "white",colour = "white")) + geom_hline(yintercept=0, size=0.5) tiff("Zero_Cluster_Only_Bar_Plot_Version_3.tiff",res=300,width=8, height=8,units="in") p3 dev.off() p4 <- ggplot(temp4, aes(fill=Cluster, y=NumberCells, x=Sample)) + geom_bar(position="fill", stat="identity") + scale_fill_manual(values=hue_pal()(length(temp0))) + labs(y="Percent Total Bins") + theme(panel.background = element_rect(fill = "white",colour = "white")) + geom_hline(yintercept=0, size=0.5) + geom_hline(yintercept=1, size=0.5) + geom_hline(yintercept=0.5, size=0.25,linetype="dashed") + geom_hline(yintercept=0.25, size=0.25,linetype="dashed")+ geom_hline(yintercept=0.75, size=0.25,linetype="dashed") p4 tiff("Zero_Cluster_Only_Bar_Plot_Version_4.tiff",res=300,width=8, height=8,units="in") p4 dev.off() ########################################### # Stacked Violin Plot # https://protect-au.mimecast.com/s/3oc1C3QNqKI9AkvwhRw2Eu?domain=divingintogeneticsandgenomics.rbind.io/ # https://protect-au.mimecast.com/s/QczfC4QOrYI90Vxyhywan6?domain=github.com ########################################### library(patchwork) modify_vlnplot<- function(obj, feature, pt.size = 0, plot.margin = unit(c(-0.75, 0, -0.75, 0), "cm"), ...) { p<- VlnPlot(obj, features = feature, pt.size = pt.size, ... ) + xlab("") + ylab(feature) + ggtitle("") + theme(legend.position = "none", axis.text.x = element_blank(), axis.ticks.x = element_blank(), axis.title.y = element_text(size = rel(1), angle = 0), axis.text.y = element_text(size = rel(1)), plot.margin = plot.margin ) return(p) } extract_max<- function(p){ ymax<- max(ggplot_build(p)$layout$panel_scales_y[[1]]$range$range) return(ceiling(ymax)) } StackedVlnPlot<- function(obj, features, pt.size = 0, plot.margin = unit(c(-0.75, 0, -0.75, 0), "cm"), ...) { plot_list<- purrr::map(features, function(x) modify_vlnplot(obj = obj,feature = x, ...)) # Add back x-axis title to bottom plot. patchwork is going to support this? plot_list[[length(plot_list)]]<- plot_list[[length(plot_list)]] + theme(axis.text.x=element_text(), axis.ticks.x = element_line()) # change the y-axis tick to only max value ymaxs<- purrr::map_dbl(plot_list, extract_max) plot_list<- purrr::map2(plot_list, ymaxs, function(x,y) x + scale_y_continuous(breaks = c(y)) + expand_limits(y = y)) p<- patchwork::wrap_plots(plotlist = plot_list, ncol = 1) return(p) } working2 <- working working2@meta.data$seurat_clusters <- factor(working2@meta.data$seurat_clusters, levels = as.character(c(0:20))) levels(working2@meta.data$seurat_clusters) tiff("Zero_Cluster_Only_Stacked_Violin_Plot.tiff",res=300,width=12, height=12,units="in") StackedVlnPlot(working2, features=rownames(working),group.by="seurat_clusters") dev.off() ####################################### # I/O ####################################### saveRDS(working,"zero.only.final.working.rds") original.working <- readRDS("original.working.rds") final.working <- readRDS("final.working.rds") ############################################################# # Repeat Primary Clustering Without Super Cluster 0 ############################################################# ffff <- subset(working, subset = nCount_RNA > 0 & nFeature_RNA > 0 & super.clusters!=1) # ffff <- SCTransform(ffff) # ffff <- RunPCA(ffff,assay="SCT",npcs=100) # e <- ElbowPlot(ffff, ndims=24,reduction="pca") # sd.cut.2.use <- 2 # dims2use <- sum(e[[1]][,2]>sd.cut.2.use) # tiff("Repeat_Primary_Analysis_Elbow_Plot.tiff",res=300,width=8, height=8,units="in") # plot(e[[1]],xlab="PC",ylab="SD",main="Elbow Plot",type='b') # abline(h=sd.cut.2.use,lwd=2,col=2,lty=2) # abline(v=dims2use,lwd=2,col=2,lty=2) # dev.off() # ffff <- FindNeighbors(ffff,dims=1:dims2use,reduction="pca") # ffff <- FindClusters(ffff) # ffff <- RunUMAP(ffff,dims=1:dims2use,reduction="pca",do.return=TRUE) tiff("Repeat_Primary_Analysis_UMAP_Plot_1.tiff",res=72,width=8, height=8,units="in") DimPlot(ffff,reduction="umap",label=FALSE) + NoLegend() dev.off() tiff("Repeat_Primary_Analysis_UMAP_Plot_2.tiff",res=72,width=8, height=8,units="in") DimPlot(ffff,reduction="umap",group.by = "Sample") dev.off() tiff("Repeat_Primary_Analysis_UMAP_Plot_3.tiff",res=72,width=8, height=8,units="in") DimPlot(ffff,reduction="umap",group.by = "Type") dev.off() tiff("Repeat_Primary_Analysis_UMAP_Plot_4.tiff",res=72,width=24, height=8,units="in") DimPlot(ffff,reduction="umap",split.by="Type",group.by="Type") dev.off() ####################################### # Repeat Secondary Super Clustering ####################################### s.clusters <- as.numeric(ffff@meta.data$seurat_clusters) ccc <- GetAssayData(object=ffff,slot="counts") ccc <- as.matrix(ccc) ddd <- ifelse(ccc==0,NA,ccc) running.clusters <- unique(sort(s.clusters)) running.means <- NULL for(i in 1:length(running.clusters)) { print(i) temp <- ddd[,s.clusters==running.clusters[i]] temp <- apply(temp,1,mean,na.rm=T) temp <- ifelse(is.na(temp),0,temp) temp <- round(temp,0) running.means <- cbind(running.means,temp) } dimnames(running.means)[[2]] <- running.clusters xxxx <- CreateSeuratObject(counts = running.means) xxxx <- subset(xxxx, subset = nCount_RNA > 0 & nFeature_RNA > 0) xxxx <- SCTransform(xxxx) xxxx <- RunPCA(xxxx,assay="SCT",npcs=100) e <- ElbowPlot(xxxx, ndims=24,reduction="pca") sd.cut.2.use <- 1 dims2use <- sum(e[[1]][,2]>sd.cut.2.use) tiff("Repeat_Super_Cluster_Elbow_Plot.tiff",res=300,width=8, height=8,units="in") plot(e[[1]],xlab="PC",ylab="SD",main="Elbow Plot",type='b') abline(h=sd.cut.2.use,lwd=2,col=2,lty=2) abline(v=dims2use,lwd=2,col=2,lty=2) dev.off() xxxx <- FindNeighbors(xxxx,dims=1:dims2use,reduction="pca") xxxx <- FindClusters(xxxx) xxxx <- RunUMAP(xxxx,dims=1:dims2use,reduction="pca",do.return=TRUE) tiff("Repeat_Super_Cluster_UMAP_Plot_1.tiff",res=300,width=8, height=8,units="in") DimPlot(xxxx,reduction="umap",label=TRUE) dev.off() super.clusters <- xxxx@meta.data$seurat_clusters ffff@meta.data$super.clusters <- rep(0,length(colnames(ffff))) for (i in 1:length(super.clusters)) { ffff@meta.data$super.clusters[s.clusters==i] <- super.clusters[i] } ffff@meta.data$super.clusters <- ffff@meta.data$super.clusters-1 ffff@meta.data$all.clusters <- ffff@meta.data$seurat_clusters ffff@meta.data$seurat_clusters <- ffff@meta.data$super.clusters tiff("Repeat_Super_Cluster_UMAP_Plot_2.tiff",res=300,width=8, height=8,units="in") DimPlot(ffff,reduction="umap",group.by="seurat_clusters",label=TRUE) dev.off() tiff("Repeat_Super_Cluster_UMAP_Plot_3.tiff",res=300,width=24, height=8,units="in") DimPlot(ffff,reduction="umap",split.by="Type",group.by="seurat_clusters",label=TRUE) dev.off() ############################################## # Save Relevant R Objects ############################################## saveRDS(working,"working.rds") saveRDS(ffff,"ffff.rds") saveRDS(xxxx,"xxxx.rds") working <- readRDS("working.rds") www <- readRDS("www.rds") ####################################### # Generate Slide Plots ####################################### unique.samples <- sort(unique(ffff@meta.data$Sample)) for(s in 1:length(unique.samples)) { print(s) # subset sample bin data new.x <- ffff@meta.data$Xpos[ffff@meta.data$Sample==unique.samples[s]] new.y <- ffff@meta.data$Ypos[ffff@meta.data$Sample==unique.samples[s]] new.clusters <- ffff@meta.data$seurat_clusters[ffff@meta.data$Sample==unique.samples[s]] my_color_palette <- hue_pal()(length(unique(ffff@meta.data$seurat_clusters))) col.2.use <- my_color_palette[as.numeric(as.character(ffff@meta.data$seurat_clusters))+1][ffff@meta.data$Sample==unique.samples[s]] # generate all detected bins plot temp <- paste(c(unique.samples[s],"_","All_Detected_Bins_Repeat_Super_Clustering_Slide_Plot.tiff"),sep="",collapse="") tiff(eval(temp),width = 28950, height = 6030, units = "px",res=300) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=sqrt(31),pch=15,axes=FALSE,xlab="",ylab="",col=8) dev.off() # generate all detected bins all clusters plot temp <- paste(c(unique.samples[s],"_","All_Detected_Bins_All_Clusters_Repeat_Super_Clustering_Slide_Plot.tiff"),sep="",collapse="") tiff(eval(temp),width = 28950, height = 6030, units = "px",res=300) plot(as.numeric(new.x),-1*as.numeric(new.y),cex=sqrt(31),pch=15,axes=FALSE,xlab="",ylab="",col=col.2.use) dev.off() # generate cluster plots for(c in 1:length(my_color_palette)) { temp <- paste(c(unique.samples[s],"_Repeat_Super_Clustering_",c-1,"_Slide_Plot.tiff"),sep="",collapse="") tiff(eval(temp),width = 28950, height = 6030, units = "px",res=300) plot(as.numeric(new.x),-1*as.numeric(new.y),col=8,pch=15,cex=sqrt(31),axes=FALSE,xlab="",ylab="") points(as.numeric(new.x[col.2.use==my_color_palette[c]]),-1*as.numeric((new.y[col.2.use==my_color_palette[c]])),col=col.2.use[col.2.use==my_color_palette[c]],cex=sqrt(31),pch=15) dev.off() } } ############################################## # Generate Dot Plots ############################################## tiff("Repeat_Super_Cluster_DotPlot.tiff",res=300,width=8, height=8,units="in") DotPlot(ffff, features = row.names(ffff),group.by="seurat_clusters") + RotatedAxis() dev.off() ############################################## # Copy output objects to Windows FileShare ############################################## # scp -vr *.tiff johnsonko@nindsdirbis7.ninds.nih.gov:/shares/PI/Alan_Koretsky/Helen_Murray/Spatial_Transcriptomics/20200501 ############################################## # Save Relevant R Objects ############################################## saveRDS(working,"working.rds") saveRDS(www,"www.rds") saveRDS(ffff,"ffff.rds") saveRDS(xxxx,"xxxx.rds") ############################################## # Stacked BarChart ############################################## library(ggplot2) library(viridis) https://protect-au.mimecast.com/s/gm_LC2xMp1UZlYQvuZPKBD?domain=r-graph-gallery.com ffff@meta.data$Type ffff <- working running.stack <- NULL temp0 <- sort(unique(ffff@meta.data$super.clusters)) for (i in 1:length(temp0)) { print(i) temp1 <- ffff@meta.data$Type[ffff@meta.data$super.clusters==temp0[i]] temp2 <- table(temp1) temp2 <- temp2[c("Control","AZ","PD")] running.stack <- rbind(running.stack,as.numeric(temp2)) } running.stack <- cbind(temp0,running.stack) dimnames(running.stack)[[2]] <- c("Cluster","Control","AZ","PD") running.stack <- as.data.frame(running.stack) running.stack$Cluster <- as.factor(running.stack$Cluster) temp3 <- running.stack[,c(1,2)] temp3 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep("Control",dim(running.stack)[1]))),NumberCells=running.stack[,c(2)]) temp4 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep("AZ",dim(running.stack)[1]))),NumberCells=running.stack[,c(3)]) temp5 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep("PD",dim(running.stack)[1]))),NumberCells=running.stack[,c(4)]) temp6 <- rbind(temp4,temp3,temp5) temp7 <- temp6[order(temp6$Cluster), ] p1 <- ggplot(temp7, aes(fill=Sample, y=NumberCells, x=Cluster)) + geom_bar(position="stack", stat="identity") + scale_fill_manual(values=hue_pal()(3)[c(1,2,3)]) + labs(y="Number Bins") + theme(panel.background = element_rect(fill = "white",colour = "white"))+ geom_hline(yintercept=0, size=0.5)+ geom_hline(yintercept=80000, size=0.5,linetype="dashed")+ geom_hline(yintercept=60000, size=0.5,linetype="dashed")+ geom_hline(yintercept=40000, size=0.5,linetype="dashed")+ geom_hline(yintercept=20000, size=0.5,linetype="dashed") p1 <- ggplot(temp7, aes(fill=Sample, y=log2(NumberCells+2), x=Cluster)) + geom_bar(position="stack", stat="identity") + scale_fill_manual(values=hue_pal()(3)[c(1,2,3)]) + labs(y="Log2(Number Bins + 2)") + theme(panel.background = element_rect(fill = "white",colour = "white")) + geom_hline(yintercept=0, size=0.5) p1 tiff("Bar_Plot_Version_1.tiff",res=300,width=8, height=8,units="in") p1 dev.off() + geom_hline(yintercept=0, size=0.5)+ geom_hline(yintercept=80000, size=0.5,linetype="dashed")+ geom_hline(yintercept=60000, size=0.5,linetype="dashed")+ geom_hline(yintercept=40000, size=0.5,linetype="dashed")+ geom_hline(yintercept=20000, size=0.5,linetype="dashed") p2 <- ggplot(temp7, aes(fill=Sample, y=NumberCells, x=Cluster)) + geom_bar(position="fill", stat="identity") + scale_fill_manual(values=hue_pal()(3)[c(1,2,3)]) + labs(y="Percent Total Bins") + theme(panel.background = element_rect(fill = "white",colour = "white")) + theme(panel.border = element_rect(colour = "black", fill=NA, size=0.5)) + geom_hline(yintercept=0, size=0.5)+ geom_hline(yintercept=0, size=0.5)+ geom_vline(xintercept=0, size=0.5) p2 <- ggplot(temp7, aes(fill=Sample, y=NumberCells, x=Cluster)) + geom_bar(position="fill", stat="identity") + scale_fill_manual(values=hue_pal()(3)[c(1,2,3)]) + labs(y="Percent Total Bins") + theme(panel.background = element_rect(fill = "white",colour = "white")) + geom_hline(yintercept=0, size=0.5) + geom_hline(yintercept=1, size=0.5) + geom_hline(yintercept=0.5, size=0.25,linetype="dashed") + geom_hline(yintercept=0.25, size=0.25,linetype="dashed")+ geom_hline(yintercept=0.75, size=0.25,linetype="dashed") tiff("Bar_Plot_Version_2.tiff",res=300,width=8, height=8,units="in") p2 dev.off() write.table(temp7,"cluster_vs_sample_class.txt",sep="\t") ######################### # Sample breakdown vs cluster ######################### ffff <- working running.stack <- NULL temp0 <- sort(unique(ffff@meta.data$seurat_clusters)) for (i in 1:length(temp0)) { print(i) temp1 <- ffff@meta.data$Sample[ffff@meta.data$seurat_clusters==temp0[i]] temp2 <- table(temp1) temp2 <- temp2[c("AZ_109_146","AZ_251_146","AZ_84_145","AZ_90_242","AZ_99_140","Control_H190_260","Control_H246_174","Control_H250_185","Control_OFB57_194","Control_OFB6A_107","PD_52_247","PD_56_236","PD_58_229","PD_77_197","PD_79_201")] temp2 <- as.numeric(temp2) temp2 <- ifelse(is.na(temp2),0,temp2) running.stack <- rbind(running.stack,as.numeric(temp2)) } running.stack <- cbind(temp0,running.stack) dimnames(running.stack)[[2]] <- c("Cluster","AZ_109_146","AZ_251_146","AZ_84_145","AZ_90_242","AZ_99_140","Control_H190_260","Control_H246_174","Control_H250_185","Control_OFB57_194","Control_OFB6A_107","PD_52_247","PD_56_236","PD_58_229","PD_77_197","PD_79_201") running.stack <- as.data.frame(running.stack) running.stack$Cluster <- as.factor(running.stack$Cluster) temp3 <- c("AZ.1","AZ.2","AZ.3","AZ.4","AZ.5","Cntrl.1","Cntrl.2","Cntrl.3","Cntrl.4","Cntrl.5","PD.1","PD.2","PD.3","PD.4","PD.5") temp4 <- NULL for (i in 1:length(temp3)) { temp5 <- data.frame(Cluster=as.factor(running.stack[,c(1)]),Sample=as.factor(c(rep(temp3[i],dim(running.stack)[1]))),NumberCells=running.stack[,c(i+1)]) temp4 <- rbind(temp4,temp5) } p3 <- ggplot(temp4, aes(fill=Cluster, y=log2(NumberCells+2), x=Sample)) + geom_bar(position="stack", stat="identity") + scale_fill_manual(values=hue_pal()(length(temp0))) + labs(y="Log2(Number Bins + 2)") + theme(panel.background = element_rect(fill = "white",colour = "white")) + geom_hline(yintercept=0, size=0.5) tiff("Bar_Plot_Version_3.tiff",res=300,width=8, height=8,units="in") p3 dev.off() p4 <- ggplot(temp4, aes(fill=Cluster, y=NumberCells, x=Sample)) + geom_bar(position="fill", stat="identity") + scale_fill_manual(values=hue_pal()(length(temp0))) + labs(y="Percent Total Bins") + theme(panel.background = element_rect(fill = "white",colour = "white")) + geom_hline(yintercept=0, size=0.5) + geom_hline(yintercept=1, size=0.5) + geom_hline(yintercept=0.5, size=0.25,linetype="dashed") + geom_hline(yintercept=0.25, size=0.25,linetype="dashed")+ geom_hline(yintercept=0.75, size=0.25,linetype="dashed") tiff("Bar_Plot_Version_4.tiff",res=300,width=8, height=8,units="in") p4 dev.off() ########################################### ########################################### ########################################### ########################################### https://protect-au.mimecast.com/s/3oc1C3QNqKI9AkvwhRw2Eu?domain=divingintogeneticsandgenomics.rbind.io/ https://protect-au.mimecast.com/s/QczfC4QOrYI90Vxyhywan6?domain=github.com library(Seurat) library(patchwork) library(ggplot2) ## remove the x-axis text and tick ## plot.margin to adjust the white space between each plot. ## ... pass any arguments to VlnPlot in Seurat modify_vlnplot<- function(obj, feature, pt.size = 0, plot.margin = unit(c(-0.75, 0, -0.75, 0), "cm"), ...) { p<- VlnPlot(obj, features = feature, pt.size = pt.size, ... ) + xlab("") + ylab(feature) + ggtitle("") + theme(legend.position = "none", axis.text.x = element_blank(), axis.ticks.x = element_blank(), axis.title.y = element_text(size = rel(1), angle = 0), axis.text.y = element_text(size = rel(1)), plot.margin = plot.margin ) return(p) } ## extract the max value of the y axis extract_max<- function(p){ ymax<- max(ggplot_build(p)$layout$panel_scales_y[[1]]$range$range) return(ceiling(ymax)) } ## main function StackedVlnPlot<- function(obj, features, pt.size = 0, plot.margin = unit(c(-0.75, 0, -0.75, 0), "cm"), ...) { plot_list<- purrr::map(features, function(x) modify_vlnplot(obj = obj,feature = x, ...)) # Add back x-axis title to bottom plot. patchwork is going to support this? plot_list[[length(plot_list)]]<- plot_list[[length(plot_list)]] + theme(axis.text.x=element_text(), axis.ticks.x = element_line()) # change the y-axis tick to only max value ymaxs<- purrr::map_dbl(plot_list, extract_max) plot_list<- purrr::map2(plot_list, ymaxs, function(x,y) x + scale_y_continuous(breaks = c(y)) + expand_limits(y = y)) p<- patchwork::wrap_plots(plotlist = plot_list, ncol = 1) return(p) } working2 <- working working2@meta.data$all.clusters <- working2@meta.data$seurat_clusters working2@meta.data$SCT_snn_res.0.8 <- working2@meta.data$seurat_clusters Idents(working2) <- working2@meta.data$seurat_clusters StackedVlnPlot(working, features=rownames(working),group.by="seurat_clusters") levels(working2@meta.data$seurat_clusters) working2 <- working working2@meta.data$seurat_clusters <- factor(working2@meta.data$seurat_clusters, levels = as.character(c(0:17))) levels(working2@meta.data$seurat_clusters) tiff("Stacked_Violin_Plot.tiff",res=300,width=12, height=12,units="in") StackedVlnPlot(working, features=rownames(working),group.by="seurat_clusters") dev.off()