This is a tutorial on quantification of confocal images. Images are assumed to be converted to RDS files already
library(RCon3D)
library(plotly)
img <- findIMG("/Data")
pwidth
is the pixel width and zstep
is the distance between the layers:
# In microns:
pwidth <- 0.75
zstep <- 0.25
myq <- quant(img,channels=c("xan","pan","mic","ste"),naming=list(Time=c("24h")))
The naming argument is optional but can be used to look through the names of the images and add corresponding variables Here it looks for “24h” in the image name, and makes a variable called Time. This is of course only useful when there are several images with different metadata: eg. Time=c(“12h”,“24h”).
myq2 <- myq
myq2$Layer <- myq2$Layer * zstep
myq2$Layer <- max(myq2$Layer) - myq2$Layer
p <- ggplot(data = myq2, aes(x = Layer, y = Count, colour = Channel, group = Channel)) +
theme_classic() +
geom_freqpoly(stat = "identity", position = position_dodge(width = 0), size = 1) +
coord_flip() +
xlab("microns from the bottom")
ggplotly(p)
fullq <- aggregate(Count ~ ., data = myq[, colnames(myq) != "Layer"], FUN = sum)
# In cubic microns
fullq$Biovolume <- fullq$Count * pwidth^2 * zstep
fullq
## Img Channel Time Count Biovolume
## 1 FourSpecies24h_xan xan 24h 3552673 499594.6
## 2 FourSpecies24h_pan pan 24h 26685719 3752679.2
## 3 FourSpecies24h_mic mic 24h 1291929 181677.5
## 4 FourSpecies24h_ste ste 24h 7192105 1011389.8
We can split the image in top, middle and bottom based on various criteria. Here we define the Top as all layers from the very top until 75 percent of the image is filled (pt = 0.75
). The bottom is the bottom 20 layers (add.b = 20
). The middle is the rest. Note that the top of the specimen is in the layers with the low numbers, hence layer.start = "Top"
. add.t
is how many layers to add to the top, after pt
calculation (e.g. pt = 0
and add.t = 10
will specify the top as the top 10 layers)
myq.split <- layer_split(myq, layer.start = "Top", side = 512, pt = 0.75, add.b = 20, add.t = 0)
myq.split$Layer <- myq.split$Layer * zstep
myq.split$Layer <- max(myq.split$Layer) - myq.split$Layer
p <- ggplot(data = myq.split, aes(x = Layer, y = Count, colour = Split, group = Split)) +
theme_classic() +
geom_freqpoly(stat = "identity", position = position_dodge(width = 0), size = 1) +
coord_flip() +
facet_grid(.~Channel) +
xlab("microns from the bottom")
ggplotly(p)