




.libPaths("/Users/eli/Documents/Tosches_Lab/Seurat5/Seurat5/renv/")

setwd("~/Documents/Tosches_Lab/Tosches_R/")

library(Seurat)

library(ggplot2)
library(cowplot)





pleuro.1<-readRDS("TP73_all_clean_broad_int_ident_MT_041525.rds")





Idents(pleuro.1)<-"TP73_type_allen"




CR_markers_pleuro<-FindMarkers(pleuro.1, ident.1 = "salamander CR", ident.2= "salamander MT", min.pct = .001, logfc.threshold= .001)


ETC_markers_pleuro<-FindMarkers(pleuro.1, ident.1 = "salamander ETC", ident.2= "salamander MT",min.pct = .001, logfc.threshold= .001  )

PV_markers_pleuro<-FindMarkers(pleuro.1, ident.1 = "salamander PV", ident.2= "salamander MT", min.pct = .001, logfc.threshold= .001 )


#####

CR_markers_pleuro$genes<-rownames(CR_markers_pleuro)
CR_markers_pleuro$pct.dif<-CR_markers_pleuro$pct.1 - CR_markers_pleuro$pct.2
CR_markers_pleuro$pct.ratio<-CR_markers_pleuro$pct.1 / CR_markers_pleuro$pct.2


ETC_markers_pleuro$genes<-rownames(ETC_markers_pleuro)
ETC_markers_pleuro$pct.dif<-ETC_markers_pleuro$pct.1 - ETC_markers_pleuro$pct.2
ETC_markers_pleuro$pct.ratio<-ETC_markers_pleuro$pct.1 /ETC_markers_pleuro$pct.2




PV_markers_pleuro$genes<-rownames(PV_markers_pleuro)
PV_markers_pleuro$pct.dif<-PV_markers_pleuro$pct.1 - PV_markers_pleuro$pct.2
PV_markers_pleuro$pct.ratio<-PV_markers_pleuro$pct.1 /PV_markers_pleuro$pct.2






CR_markers_pleuro_up<-subset(CR_markers_pleuro, (CR_markers_pleuro$p_val_adj<.001 & CR_markers_pleuro$avg_log2FC>.5 & CR_markers_pleuro$pct.dif>.25 & CR_markers_pleuro$pct.ratio>2 ))

CR_markers_pleuro_low<-subset(CR_markers_pleuro,  CR_markers_pleuro$pct.1 < .25 )

CR_markers_pleuro_down<-subset(CR_markers_pleuro, 
                               (CR_markers_pleuro$p_val_adj<.001 & CR_markers_pleuro$avg_log2FC<(-.5) & CR_markers_pleuro$pct.dif<(-.25) & CR_markers_pleuro$pct.ratio<.5 ))



ETC_markers_pleuro_up<-subset(ETC_markers_pleuro, (ETC_markers_pleuro$p_val_adj<.001 & ETC_markers_pleuro$avg_log2FC>.5 & ETC_markers_pleuro$pct.dif>.25 & ETC_markers_pleuro$pct.ratio>2))

ETC_markers_pleuro_low<-subset(ETC_markers_pleuro,  ETC_markers_pleuro$pct.1 < .25 )

ETC_markers_pleuro_down<-subset(ETC_markers_pleuro, 
                                (ETC_markers_pleuro$p_val_adj<.001 & ETC_markers_pleuro$avg_log2FC<(-.5) & ETC_markers_pleuro$pct.dif<(-.25) & ETC_markers_pleuro$pct.ratio<.5))






PV_markers_pleuro_up<-subset(PV_markers_pleuro, (PV_markers_pleuro$p_val_adj<.001 & PV_markers_pleuro$avg_log2FC>.5 & PV_markers_pleuro$pct.dif>.25 & PV_markers_pleuro$pct.ratio>2))

PV_markers_pleuro_low<-subset(PV_markers_pleuro,  PV_markers_pleuro$pct.1 < .25 )

PV_markers_pleuro_down<-subset(PV_markers_pleuro, 
                               (PV_markers_pleuro$p_val_adj<.001 & PV_markers_pleuro$avg_log2FC<(-.5) & PV_markers_pleuro$pct.dif<(-.25) & PV_markers_pleuro$pct.ratio<.5))






mouse.1 <- readRDS("mouse_allen_TP73_MT_merge_111124.rds")

DimPlot(mouse.1, group.by = "broad_ident")

Idents(mouse.1)<-"broad_ident"








CR_markers_mouse<-FindMarkers(mouse.1, ident.1 = "mouse CR", ident.2= "mouse MT", min.pct = .001, logfc.threshold= .001 )


ETC_markers_mouse<-FindMarkers(mouse.1, ident.1 = "mouse ETC", ident.2= "mouse MT", min.pct = .001, logfc.threshold= .001 )

PV_markers_mouse<-FindMarkers(mouse.1, ident.1 = "mouse PV", ident.2= "mouse MT",  min.pct = .001, logfc.threshold= .001 )


#####

CR_markers_mouse$genes<-rownames(CR_markers_mouse)
CR_markers_mouse$pct.dif<-CR_markers_mouse$pct.1 - CR_markers_mouse$pct.2
CR_markers_mouse$pct.ratio<-CR_markers_mouse$pct.1 / CR_markers_mouse$pct.2


ETC_markers_mouse$genes<-rownames(ETC_markers_mouse)
ETC_markers_mouse$pct.dif<-ETC_markers_mouse$pct.1 - ETC_markers_mouse$pct.2
ETC_markers_mouse$pct.ratio<-ETC_markers_mouse$pct.1 /ETC_markers_mouse$pct.2




PV_markers_mouse$genes<-rownames(PV_markers_mouse)
PV_markers_mouse$pct.dif<-PV_markers_mouse$pct.1 - PV_markers_mouse$pct.2
PV_markers_mouse$pct.ratio<-PV_markers_mouse$pct.1 /PV_markers_mouse$pct.2






CR_markers_mouse_up<-subset(CR_markers_mouse, (CR_markers_mouse$p_val_adj<.001 & CR_markers_mouse$avg_log2FC>.5 & CR_markers_mouse$pct.dif>.25 & CR_markers_mouse$pct.ratio>2 ))


CR_markers_mouse_low<-subset(CR_markers_mouse,  CR_markers_mouse$pct.1 < .25 )



CR_markers_mouse_down<-subset(CR_markers_mouse, 
                              (CR_markers_mouse$p_val_adj<.001 & CR_markers_mouse$avg_log2FC<(-.5) & CR_markers_mouse$pct.dif<(-.25) & CR_markers_mouse$pct.ratio<.5 ))





ETC_markers_mouse_up<-subset(ETC_markers_mouse, (ETC_markers_mouse$p_val_adj<.001 & ETC_markers_mouse$avg_log2FC>.5 & ETC_markers_mouse$pct.dif>.25 & ETC_markers_mouse$pct.ratio>2))


ETC_markers_mouse_low<-subset(ETC_markers_mouse,  ETC_markers_mouse$pct.1 < .25 )


ETC_markers_mouse_down<-subset(ETC_markers_mouse, 
                               (ETC_markers_mouse$p_val_adj<.001 & ETC_markers_mouse$avg_log2FC<(-.5) & ETC_markers_mouse$pct.dif<(-.25) & ETC_markers_mouse$pct.ratio<.5))






PV_markers_mouse_up<-subset(PV_markers_mouse, (PV_markers_mouse$p_val_adj<.001 & PV_markers_mouse$avg_log2FC>.5 & PV_markers_mouse$pct.dif>.25 & PV_markers_mouse$pct.ratio>2))


PV_markers_mouse_low<-subset(PV_markers_mouse,  PV_markers_mouse$pct.1 < .25 )


PV_markers_mouse_down<-subset(PV_markers_mouse, 
                              (PV_markers_mouse$p_val_adj<.001 & PV_markers_mouse$avg_log2FC<(-.5) & PV_markers_mouse$pct.dif<(-.25) & PV_markers_mouse$pct.ratio<.5))








####




eggnog_mouse <- read.table("mus_eggnog_pruned.txt" , header=T)



CR_markers_mouse_up_genes<-subset(eggnog_mouse, eggnog_mouse$mouse%in%CR_markers_mouse_up$genes)$eggnog




ETC_markers_mouse_up_genes<-subset(eggnog_mouse, eggnog_mouse$mouse%in%ETC_markers_mouse_up$genes)$eggnog



PV_markers_mouse_up_genes<-subset(eggnog_mouse, eggnog_mouse$mouse%in%PV_markers_mouse_up$genes)$eggnog





CR_markers_mouse_low_genes<-subset(eggnog_mouse, eggnog_mouse$mouse%in%CR_markers_mouse_low$genes)$eggnog




ETC_markers_mouse_low_genes<-subset(eggnog_mouse, eggnog_mouse$mouse%in%ETC_markers_mouse_low$genes)$eggnog



PV_markers_mouse_low_genes<-subset(eggnog_mouse, eggnog_mouse$mouse%in%PV_markers_mouse_low$genes)$eggnog






###

CR_markers_pleuro_up_genes<-subset(CR_markers_pleuro_up, CR_markers_pleuro_up$genes %in% eggnog_mouse$eggnog)$genes


ETC_markers_pleuro_up_genes<-subset(ETC_markers_pleuro_up, ETC_markers_pleuro_up$genes %in% eggnog_mouse$eggnog)$genes

PV_markers_pleuro_up_genes<-subset(PV_markers_pleuro_up, PV_markers_pleuro_up$genes %in% eggnog_mouse$eggnog)$genes



CR_markers_pleuro_low_genes<-subset(CR_markers_pleuro_low, CR_markers_pleuro_low$genes %in% eggnog_mouse$eggnog)$genes


ETC_markers_pleuro_low_genes<-subset(ETC_markers_pleuro_low, ETC_markers_pleuro_low$genes %in% eggnog_mouse$eggnog)$genes

PV_markers_pleuro_low_genes<-subset(PV_markers_pleuro_low, PV_markers_pleuro_low$genes %in% eggnog_mouse$eggnog)$genes





#######

###### Run analysis on all genes 

#### Need to decide here if scope is intersect or union 



union_genes<-union(
  union(union(CR_markers_mouse_up_genes, ETC_markers_mouse_up_genes), PV_markers_mouse_up_genes),
  
  union(union(CR_markers_pleuro_up_genes, ETC_markers_pleuro_up_genes), PV_markers_pleuro_up_genes)
)






genes_df<-data.frame(row.names = union_genes)


genes_df$pleuro_CR_up<-ifelse(rownames(genes_df)%in%CR_markers_pleuro_up_genes, 1, 0)

genes_df$pleuro_ETC_up<-ifelse(rownames(genes_df)%in%ETC_markers_pleuro_up_genes, 1, 0)

genes_df$pleuro_PV_up<-ifelse(rownames(genes_df)%in%PV_markers_pleuro_up_genes, 1, 0)




genes_df$pleuro_CR_low<-ifelse(rownames(genes_df)%in%CR_markers_pleuro_low_genes, 1, 0)

genes_df$pleuro_ETC_low<-ifelse(rownames(genes_df)%in%ETC_markers_pleuro_low_genes, 1, 0)

genes_df$pleuro_PV_low<-ifelse(rownames(genes_df)%in%PV_markers_pleuro_low_genes, 1, 0)






genes_df$mouse_CR_up<-ifelse(rownames(genes_df)%in%CR_markers_mouse_up_genes, 1, 0)

genes_df$mouse_ETC_up<-ifelse(rownames(genes_df)%in%ETC_markers_mouse_up_genes, 1, 0)

genes_df$mouse_PV_up<-ifelse(rownames(genes_df)%in%PV_markers_mouse_up_genes, 1, 0)





genes_df$mouse_CR_low<-ifelse(rownames(genes_df)%in%CR_markers_mouse_low_genes, 1, 0)

genes_df$mouse_ETC_low<-ifelse(rownames(genes_df)%in%ETC_markers_mouse_low_genes, 1, 0)

genes_df$mouse_PV_low<-ifelse(rownames(genes_df)%in%PV_markers_mouse_low_genes, 1, 0)







pleuro_CR_Specific_genes<-rownames(subset(genes_df, 
                                          (genes_df$pleuro_CR_up=="1" &   genes_df$pleuro_ETC_up=="0"&  
                                             genes_df$mouse_CR_up=="0"  
                                           &genes_df$mouse_CR_low=="1" & genes_df$pleuro_ETC_low=="1"
                                          ) 
))



mouse_CR_Specific_genes<-rownames(subset(genes_df, 
                                         (genes_df$pleuro_CR_up=="0" &    
                                            genes_df$mouse_CR_up=="1" &   genes_df$mouse_ETC_up=="0" 
                                          & genes_df$pleuro_CR_low == "1"  & genes_df$mouse_ETC_low == "1"
                                         ) 
))




pleuro_CR_Upreg_genes<-rownames(subset(genes_df, 
                                 (genes_df$pleuro_CR_up=="1" &   
                                    genes_df$mouse_CR_up=="0" &   genes_df$mouse_CR_low=="1"  ) 
))







mouse_CR_Upreg_genes<-rownames(subset(genes_df, 
                                (genes_df$mouse_CR_up=="1" &   
                                   genes_df$pleuro_CR_up=="0" &   genes_df$pleuro_CR_low=="1"  ) 
))



shared_CR_Upreg_genes<-rownames(subset(genes_df, 
                                 (genes_df$mouse_CR_up=="1" &   
                                    genes_df$pleuro_CR_up=="1"  ) 
))




CR_share_Specific_genes<-rownames(subset(genes_df, 
                                    (genes_df$pleuro_CR_up=="1" &   genes_df$pleuro_ETC_up=="0"&
                                       genes_df$mouse_CR_up=="1" &   genes_df$mouse_ETC_up=="0" &
                                     genes_df$pleuro_ETC_low=="1" &   genes_df$mouse_ETC_low=="1" ) 
))







pleuro_CR_Specific_eggnog<-subset(eggnog_mouse, eggnog_mouse$eggnog %in% pleuro_CR_Specific_genes)


mouse_CR_Specific_eggnog<-subset(eggnog_mouse, eggnog_mouse$eggnog %in% mouse_CR_Specific_genes)



pleuro_CR_Upreg_eggnog<-subset(eggnog_mouse, eggnog_mouse$eggnog %in% pleuro_CR_Upreg_genes)


mouse_CR_Upreg_eggnog<-subset(eggnog_mouse, eggnog_mouse$eggnog %in% mouse_CR_Upreg_genes)




shared_CR_Upreg_eggnog<-subset(eggnog_mouse, eggnog_mouse$eggnog %in% shared_CR_Upreg_genes)


CR_share_Specific_eggnog<-subset(eggnog_mouse, eggnog_mouse$eggnog %in% CR_share_Specific_genes)





list_order_pleuro_CR_Upreg<-c(intersect(pleuro_CR_Upreg_eggnog$eggnog, pleuro_CR_Specific_eggnog$eggnog), setdiff(pleuro_CR_Upreg_eggnog$eggnog, pleuro_CR_Specific_eggnog$eggnog))


list_order_mouse_CR_Upreg<-c(intersect(mouse_CR_Upreg_eggnog$eggnog, mouse_CR_Specific_eggnog$eggnog), setdiff(mouse_CR_Upreg_eggnog$eggnog, mouse_CR_Specific_eggnog$eggnog))


list_order_shared_CR_Upreg<-c(intersect(shared_CR_Upreg_eggnog$eggnog, CR_share_Specific_eggnog$eggnog), setdiff(shared_CR_Upreg_eggnog$eggnog, CR_share_Specific_eggnog$eggnog))






pleuro_CR_Upreg_eggnog_order<-pleuro_CR_Upreg_eggnog[match(list_order_pleuro_CR_Upreg, pleuro_CR_Upreg_eggnog$eggnog), ]


mouse_CR_Upreg_eggnog_order<-mouse_CR_Upreg_eggnog[match(list_order_mouse_CR_Upreg, mouse_CR_Upreg_eggnog$eggnog), ]


shared_CR_Upreg_eggnog_order<-shared_CR_Upreg_eggnog[match(list_order_shared_CR_Upreg, shared_CR_Upreg_eggnog$eggnog), ]





invin_signaling_receptor_activity_ms <- read_csv("invin_signaling_receptor_activity_ms.txt", 
                                                 col_names = FALSE)






invin_signaling_receptor_binding_ms <- read_csv("invin_signaling_receptor_binding_ms.txt", 
                                                col_names = FALSE)


Mouse_TF <- read_table("Mus_musculus_TF.txt")


#####


pleuro_CR_Upreg_eggnog_order_SRA<-subset(pleuro_CR_Upreg_eggnog_order, pleuro_CR_Upreg_eggnog_order$mouse %in% invin_signaling_receptor_activity_ms$X1)




pleuro_CR_Upreg_eggnog_order_SRB<-subset(pleuro_CR_Upreg_eggnog_order, pleuro_CR_Upreg_eggnog_order$mouse %in% invin_signaling_receptor_binding_ms$X1)



pleuro_CR_Upreg_eggnog_order_TF<-subset(pleuro_CR_Upreg_eggnog_order, pleuro_CR_Upreg_eggnog_order$mouse %in% Mouse_TF$Symbol)


##
pleuro_CR_Upreg_eggnog_order_anno<-rbind(pleuro_CR_Upreg_eggnog_order_SRA, pleuro_CR_Upreg_eggnog_order_SRB, pleuro_CR_Upreg_eggnog_order_TF)
write_csv(pleuro_CR_Upreg_eggnog_order_anno, file = "pleuro_CR_Upreg_eggnog_order_anno.csv")
###



mouse_CR_Upreg_eggnog_order_SRA<-subset(mouse_CR_Upreg_eggnog_order, mouse_CR_Upreg_eggnog_order$mouse %in% invin_signaling_receptor_activity_ms$X1)




mouse_CR_Upreg_eggnog_order_SRB<-subset(mouse_CR_Upreg_eggnog_order, mouse_CR_Upreg_eggnog_order$mouse %in% invin_signaling_receptor_binding_ms$X1)



mouse_CR_Upreg_eggnog_order_TF<-subset(mouse_CR_Upreg_eggnog_order, mouse_CR_Upreg_eggnog_order$mouse %in% Mouse_TF$Symbol)



##
mouse_CR_Upreg_eggnog_order_anno<-rbind(mouse_CR_Upreg_eggnog_order_SRA, mouse_CR_Upreg_eggnog_order_SRB, mouse_CR_Upreg_eggnog_order_TF)
write_csv(mouse_CR_Upreg_eggnog_order_anno, file = "mouse_CR_Upreg_eggnog_order_anno.csv")

Idents(sal.dev)<-"orig.ident"

mouse_cr_genes_pw_dp<-DotPlot(sal.dev, features = unique(mouse_CR_Upreg_eggnog_order_anno$eggnog))

length(unique(mouse_CR_Upreg_eggnog_order_anno$eggnog))

View(mouse_cr_genes_pw_dp$data)
length(mouse_cr_genes_pw_dp$data$features.plot)

###




shared_CR_Upreg_eggnog_order_SRA<-subset(shared_CR_Upreg_eggnog_order, shared_CR_Upreg_eggnog_order$mouse %in% invin_signaling_receptor_activity_ms$X1)




shared_CR_Upreg_eggnog_order_SRB<-subset(shared_CR_Upreg_eggnog_order, shared_CR_Upreg_eggnog_order$mouse %in% invin_signaling_receptor_binding_ms$X1)



shared_CR_Upreg_eggnog_order_TF<-subset(shared_CR_Upreg_eggnog_order, shared_CR_Upreg_eggnog_order$mouse %in% Mouse_TF$Symbol)





####



#mouse.1<-SCTransform(mouse.1, variable.features.n = 20000)
#pleuro.1<-SCTransform(pleuro.1, variable.features.n = 20000)



pdf("pleuro_CR_Upreg_eggnog_order_SRA_pw.pdf", width = 4, height = length(pleuro_CR_Upreg_eggnog_order_SRA$eggnog))
 VlnPlot(pleuro.1, pleuro_CR_Upreg_eggnog_order_SRA$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
  theme(legend.position = "none")
dev.off()
 
 pdf("pleuro_CR_Upreg_eggnog_order_SRA_mm.pdf", width = 4, height = length(pleuro_CR_Upreg_eggnog_order_SRA$eggnog))
 VlnPlot(mouse.1, setdiff(pleuro_CR_Upreg_eggnog_order_SRA$mouse, "Adgre5"), stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
  theme(legend.position = "none")
dev.off()
   


 

pdf("mouse_CR_Upreg_eggnog_order_SRA_pw.pdf", width = 4, height = length(mouse_CR_Upreg_eggnog_order_SRA$eggnog))
 VlnPlot(pleuro.1, mouse_CR_Upreg_eggnog_order_SRA$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none")
 dev.off()
 
 
 
 
 
 b<-VlnPlot(mouse.1, mouse_CR_Upreg_eggnog_order_SRA$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
pdf("mouse_CR_Upreg_eggnog_order_SRA_mm.pdf", width = 4, height = length(levels(b$data$feature)))
b
dev.off()
 



 
 b<-VlnPlot(pleuro.1, shared_CR_Upreg_eggnog_order_SRA$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none") 
 
 pdf("shared_CR_Upreg_eggnog_order_SRA_pw.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 
 
 
 b<-VlnPlot(mouse.1, shared_CR_Upreg_eggnog_order_SRA$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
 
 pdf("shared_CR_Upreg_eggnog_order_SRA_mm.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 
 
 
 ########
 
 
 
 
 b<-VlnPlot(pleuro.1, pleuro_CR_Upreg_eggnog_order_SRB$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none")
 pdf("pleuro_CR_Upreg_eggnog_order_SRB_pw.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 
 b<-VlnPlot(mouse.1, pleuro_CR_Upreg_eggnog_order_SRB$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
 pdf("pleuro_CR_Upreg_eggnog_order_SRB_mm.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 

 
 
 
 b<-VlnPlot(pleuro.1, mouse_CR_Upreg_eggnog_order_SRB$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none")
 pdf("mouse_CR_Upreg_eggnog_order_SRB_pw.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 
 b<-VlnPlot(mouse.1, mouse_CR_Upreg_eggnog_order_SRB$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
 pdf("mouse_CR_Upreg_eggnog_order_SRB_mm.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 
 
 
 b<-VlnPlot(pleuro.1, shared_CR_Upreg_eggnog_order_SRB$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none") 
 
 pdf("shared_CR_Upreg_eggnog_order_SRB_pw.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 
 
 
 b<-VlnPlot(mouse.1, shared_CR_Upreg_eggnog_order_SRB$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
 
 pdf("shared_CR_Upreg_eggnog_order_SRB_mm.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 
 
 
 ####
 
 
 
 
 b<-VlnPlot(pleuro.1, pleuro_CR_Upreg_eggnog_order_TF$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none")
 pdf("pleuro_CR_Upreg_eggnog_order_TF_pw.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 
 b<-VlnPlot(mouse.1, pleuro_CR_Upreg_eggnog_order_TF$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
 pdf("pleuro_CR_Upreg_eggnog_order_TF_mm.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 
 
 
 
 
 b<-VlnPlot(pleuro.1, mouse_CR_Upreg_eggnog_order_TF$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none")
 pdf("mouse_CR_Upreg_eggnog_order_TF_pw.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 
 b<-VlnPlot(mouse.1, mouse_CR_Upreg_eggnog_order_TF$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
 pdf("mouse_CR_Upreg_eggnog_order_TF_mm.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 
 
 
 b<-VlnPlot(pleuro.1, shared_CR_Upreg_eggnog_order_TF$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none") 
 
 pdf("shared_CR_Upreg_eggnog_order_TF_pw.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 
 
 
 b<-VlnPlot(mouse.1, shared_CR_Upreg_eggnog_order_TF$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
 
 pdf("shared_CR_Upreg_eggnog_order_TF_mm.pdf", width = 4, height = length(levels(b$data$feature)))
 b
 dev.off()
 
 
 
 
 
 
 #####
 
 
 
 
 VlnPlot(pleuro.1, pleuro_CR_Upreg_eggnog_order_SRB$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none")
 
 
 VlnPlot(mouse.1, pleuro_CR_Upreg_eggnog_order_SRB$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
 
 
 
 
 
 
 VlnPlot(pleuro.1, mouse_CR_Upreg_eggnog_order_SRB$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none")
 
 
 VlnPlot(mouse.1, mouse_CR_Upreg_eggnog_order_SRB$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
 
 
 
 
 
 
 
 VlnPlot(pleuro.1, shared_CR_Upreg_eggnog_order_SRB$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none")
 
 
 VlnPlot(mouse.1, shared_CR_Upreg_eggnog_order_SRB$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
 
 
 ######
 
 
 ##
 
 
###
 
 
 
 
 
 
 
 
 VlnPlot(pleuro.1, pleuro_CR_Upreg_eggnog_order_TF$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none")
 
 
 VlnPlot(mouse.1, pleuro_CR_Upreg_eggnog_order_TF$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
 
 
 
 
 
 
 VlnPlot(pleuro.1, mouse_CR_Upreg_eggnog_order_TF$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none")
 
 
 VlnPlot(mouse.1, mouse_CR_Upreg_eggnog_order_TF$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
 
 
 
 
 
 
 
 VlnPlot(pleuro.1, shared_CR_Upreg_eggnog_order_TF$eggnog, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("salamander CR","salamander ETC")) +
   theme(legend.position = "none")
 
 
 VlnPlot(mouse.1, shared_CR_Upreg_eggnog_order_TF$mouse, stack = TRUE, sort = FALSE, flip = TRUE, idents = c("mouse CR","mouse ETC")) +
   theme(legend.position = "none")
 
 
 
 
 
 
 


