-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGreyScaleTo_bmp.R
More file actions
69 lines (60 loc) · 1.84 KB
/
GreyScaleTo_bmp.R
File metadata and controls
69 lines (60 loc) · 1.84 KB
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
# Creation of 236 greyscale images (.bmp) from gated data
# Code used
source("flowDiv_internals.R")
source("flowDiv_main.R")
# Packages used
library("vegan")
library("flowWorkspace")
library("ggplot2")
library("ggcyto")
library("plyr")
library("car")
library("corrplot")
library("pangaear")
library("ggbiplot")
library("psych")
library("cowplot")
library("RColorBrewer")
# Parsing data
## MyWorkspace.wsp is a FlowJo workspace with 31 samples
## "Bact tot" os the gate of insterest
wksp=opc("MyWorkspace.wsp")
samples=nn(wksp,nod = "Bact tot", use.beads = F, nod2="NULL")
# Getting informations on channels FL1 and SSC
## FL1
fl1=unlist(lapply(samples$nodesample[[1]], function(x)exprs(x$"FL1-H")))
max(fl1)
min(fl1)
## SSC
ssc=unlist(lapply(samples$nodesample[[1]], function(x)exprs(x$"SSC-H")))
max(ssc)
min(ssc)
#Generate all colors needed
myColors <- gray.colors(236)
#Reverse it as you want dark for high and white for low
myColors <- rev(myColors)
#Wrap it into a ramp function
myColRamp <- colorRampPalette(myColors)
# plotbmp function
plotbmp<-function(x,y){
flowdf=data.frame((exprs(x)))
# Cytograms in greyscales (236)
gplot=ggplot(flowdf, aes(y=FL1.H, x=SSC.H))+
geom_hex(bins = 128, na.rm = T)+
scale_fill_gradientn("", colours = rev(gray.colors(236, end = 5/6)))+
theme_bw()+
scale_x_continuous(limits= c(0.34,1.25)) +
scale_y_continuous(limits= c(0.34, 1.25)) +
theme(panel.border = element_blank(),
axis.line = element_line(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank())+
theme(legend.position="none")
ggsave(y,gplot, device = "bmp")
}
# Saving as bmp files
mapply(function(z,w)plotbmp(z,w), samples$nodesample[[1]], samples$names)