-
Notifications
You must be signed in to change notification settings - Fork 1
/
Figure1_CellTypes.Rmd
91 lines (82 loc) · 3.82 KB
/
Figure1_CellTypes.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
title: "Code For Figure 1_CellTypes"
author: "Mike Dolan"
output: html_document
---
This is the code for figure 1. All PDFs are sent to SplitGAL4_Paper/Figures/Figure1.
Load up the required packages and link to Google Drive
```{r, echo=FALSE, results="hide"}
library(here) #Sets the root directory, use here() to call it
library(ggplot2)
library(xlsx)
library(dplyr)
here()
file.symlink("/Users/dolanm/Google Drive/SplitGAL4_Paper/Figures/Figure1", here())
```
Load in the data from the NA_master file and plot the number of anatomical groups covered by good or ideal lines
```{r, echo=FALSE}
TypeFreq<-read.xlsx("Figure1/Neuroanatomy_Master.xlsx",1)
TypeFreq<-select(TypeFreq, 1:4)
TypeFreq[is.na(TypeFreq)]<-0
TypeFreq<-mutate(TypeFreq, NAgood=NAgood+Ideal)
totalclust<-length(TypeFreq[,1])
Totals<-rbind(totalclust-length(filter(TypeFreq, NAgood==0)[,1]),totalclust - length(filter(TypeFreq, Ideal==0)[,1]))
```
Short code to determine how many cell-types (rather than anatomical groups) are covered in the screen. How many of those are single cell-types and how many are unitary groups of more than one cell-type that cooccur in the split-GAL4 lines
```{r, echo=FALSE}
celltype<-as.character(TypeFreq$FinalNames)
celltype<-na.omit(celltype)
Single_celltype<-length(grep(pattern = "/", x = celltype, value = TRUE, invert = TRUE))-1 #Remove the 4As from singletons
double_celltype<-2*(length(grep(pattern = "/", x = celltype, value = TRUE)))
Single_celltype+double_celltype+5 #for 4A
```
Plot the Cell-Type coverage
```{r, echo=FALSE}
pdf(here("Figure1/CellType_coverage.pdf"), width = 2.57, height = 4.68)
barplot(Totals, names=c("Good", "Ideal"), ylim=c(0,totalclust), ylab="Anatomy Groups Covered"
, col=c("blue", "orange"), axes=FALSE, beside=TRUE, cex.lab=1.2, cex.names=1.2, width=2)
axis(2, at = c(0, 20, 40, 60, 80, totalclust))
dev.off()
```
Plot the frequency of Good and Ideal Split-GAL4 lines for each cell-type (need to change names)
```{r, echo=FALSE}
pdf(here("Figure1/IdealandGood_coverage.pdf"), width = 10, height = 6)
TypeFreq_Plot<-filter(TypeFreq, NAgood!=0)
TypeFreq_Plot<-arrange(TypeFreq_Plot, desc(TypeFreq_Plot[,2]), desc(TypeFreq_Plot[,3]))
barplot(height=(TypeFreq_Plot[,2]), names.arg=TypeFreq_Plot[,4], col="blue", xlab=""
, ylab="Frequency", cex.names=.7, las=2, horiz = F, space=0.4, mgp=c(1.8,0.6,0))
barplot(height=(TypeFreq_Plot[,3]), col="orange", cex.names=.7, las=2, add=TRUE, horiz = F, space=0.4, mgp=c(1.8,0.6,0))
dev.off()
```
Plot the total number lines screened and the number of line we found.
```{r, echo=FALSE}
num_screened<-2444
num_imaged<-1095
num_annotated<-410
num_good<-259 #Have subtracted the number of ideals
num_Ideal<-123
screened<-data.frame(group=c("Total Lines Screened", "Good Lines", "Ideal Lines"),
value=c(num_screened-num_good-num_Ideal, num_good, num_Ideal))
pdf(here("Figure1/Screen_overview.pdf"), width = 3.46, height = 4.68)
g<-ggplot(screened, aes(x="", y=value, fill=group))
g<-g+scale_y_continuous( breaks=c(0, 500, 1000, 1500, 2000, num_screened))
g<-g+geom_bar(width=1, stat="identity", color="black")
g<-g+coord_cartesian(expand = FALSE)
g<-g+labs(y="Number of Split-GAL4 lines", x="")
g<-g+guides(fill=guide_legend(title=NULL))
g<-g+scale_fill_manual(values=c("blue","#E69F00", "#999999" ))
g
dev.off()
```
Some code to do the same as above in base R plot for consistancy.
```{r, echo=FALSE}
ticks<-seq(from=0, to=2000, 250)
screened<-c(num_screened,num_imaged, num_good,num_Ideal)
screened<-desc(screened)
pdf(here("Figure1/Screen_Overview_base.pdf"), width = 9.91, height = 4.68)
barplot(screened, names=c("Total", "Imaged" , "Good", "Ideal"), xlab="Number of Split-GAL4 lines"
, col=c("grey", "forest green", "blue", "orange"), beside=TRUE, axes = FALSE, horiz = TRUE
, cex.names=1.2)
axis(1, at = c(ticks, num_screened))
dev.off()
```