time lapse analysis - veeninglab/BactMAP GitHub Wiki
Function to plot cell fluorescence from a TIFF over time.
plotCellsTime(celdat, updown = T, movie = F, viridisoption = "magma", cellN, minf, maxf)
Argument | Description |
---|---|
celdat |
TIFF and mesh outline data from a timelapse movie as it was obtained by running extr_OriginalCells.
|
updown |
When updown ==TRUE , a horizontal cell tower is made, otherwise, the cells are displayed left-right. movie ==TRUE will overwrite this and return an animation instead. |
movie |
When movie == TRUE , an animation made with gganimate is returned. |
viridisoption |
The color palette used. The default palettes are part of the viridis color palettes (default = magma ). |
cellN |
The cell number or numbers to be displayed. When not indicated, a list of plots of all cells will be made. |
minf |
The minimum frame to be displayed. |
maxf |
The maximum frame to be displayed |
A plot, list of plots or animation of a single cell’s fluorescence over time.
##In the BactMAP example dataset ( for download see https://veeninglab.com/bactmap),
##the raw data of one cell is saved as "TurnedCell4":
load("TurnedCell4.rda")
#to plot a left-right tower:
plotCellsTime(TurnedCell4, updown=F, viridisoption="inferno", minf=1, maxf=10)
## [[1]]
#or to create an animation:
plotCellsTime(bactMAP::TurnedCell4, movie=T)
Filter timelapse data by growth speed and whether cells underwent a whole division cycle.
The function takes timelapse dataframes including cell size, frame and cell ID and return a dataframe with information on growth speed, whether the cell underwent a full division (and how many divisions), and a binning of each cell division in percentages. Next to this, it gives a summary of the parameters in the input dataframe per binned division point. It also plots the individual cell growth over binned division, as well as the average cell growth.
perc_Division(timelapse, av = TRUE, plotgrowth = TRUE)
Arguments | Description |
---|---|
timelapse |
A dataframe from timelapse data containing at least the variables frame , cell and max.length.
|
av |
When av ==TRUE , the function returns a dataframe with the variables of the input dataframe averaged per binned division moment (percentage_binned ). |
plotgrowth |
When plotgrowth ==TRUE , the function returns a plot of the cell growth by binned division point, growth speed and nth division. |
This function estimates whether a division is a “full” division by a set of cutoffs. In some cases, the segmentation data gives this information already. When this is the case, it can be more straightforward to use this data instead of this function.
BactKymo inherits this function when the average fluorescence over time is plotted as a kymograph
- A dataframe
timelapse
containing the following variables on top of the variables already in the input dataframe:
Variable | Description |
---|---|
division |
the nth division in the timelapse this cell is making |
min_frame |
the frame number where this division starts |
max_frame |
the frame where the cell is dividing |
av_length |
the mean cell length over the whole division |
length_var |
the variance of the cell length during the whole division |
division_time |
the time this division takes (in frames) |
fulldivision |
indicates whether the division is a full division (1 = full) |
coeff |
the coefficient of the linear growth function of the cell for this division - indicator of growth speed |
growth |
the divisions are grouped in 4 groups: no growth ("none" ), fast , medium and slow growth. |
percentage |
if the moment of cell birth is 0 and cell division is 100, the percentage gives how far the cell is from dividing at this moment |
percentage_binned |
percentage grouped in 10 groups, for averaging |
-
A dataframe
mean_by_percentage
, where the variables are averaged over percentage_binned. -
A ggplot
plot_growth
showing the cell size over the percentage of division. -
A ggplot
plot_avgrowth
showing the average cell size over the percentage of division.
The example below doesn’t have much biological meaning, since this data doesn’t contain many complete cell cycles. It runs fast though and is available through the example folder so it is easy to try the function out!
If you’re interested in something more complex, check out our examples and tutorials, where I go through some larger datasets.
#load example dataset
load("FtsZ_tracks.rda")
percD <- perc_Division(FtsZ_tracks)
percD$plot_avgrowth
Plot cell genealogy information as networks using ggtree.
This function is using the
ggtree
package to show
cell genealogy combined with cell information, e.g. fluorescence
intensity. This part of bactMAP is under development - plotting cell
trees is possible, but is not (yet) as straight-forward. Check the
tutorials here on this wiki or on
veeninglab.com/bactmap to get more information
on how to use this function.
plotTreeBasic(phylo,
extradata,
yscalechange = FALSE,
showClade = FALSE,
layout = "rectangular",
ydata,
cellNumber,
open.angle,
linesize = 1,
linecolor = "black",
lines = TRUE,
colors = FALSE)
Argument | Description |
---|---|
phylo |
The $generation_lists output of extr_SuperSegger or extr_Oufti. |
extradata |
Data connected to the $generation_lists : $generation_dataframes . When this is added, the output of the plot looks the same, but it is possible to add layers to the plots with cell information using the ggtree-commands. See the tutorials for more information. |
yscalechange |
Default = FALSE . When TRUE , an y-axis is added to the tree. Only works when also indicating what needs to be plotted on the y-axis (indicate by putting the column name of choice from extradata as input in ydata ). |
showClade |
When showClade ==TRUE , one clade will be highlighted. Decide which one by putting a cell number in cellNumber.
|
layout |
Inherited from ggtree ; this decides the shape of the plotted tree. Options: "rectangular" , "slanted" , "fan" , "circular" , "radial" , "unrooted" , "equal_angle" , "daylight"
|
ydata |
Indicate the column name of the variable you want to be plotted on the y-axis of the tree (when yscalechange ==TRUE ). |
cellNumber |
Indicate the number of the cell of which you want to highlight the clade (when showClade ==TRUE ). |
open.angle |
When layout =="fan" , indicate the size of the open angle (in degrees) here. |
linesize |
Thickness of the lines in the tree. |
linecolor |
Indicate the color of the lines in the tree. |
lines |
When highlighting a clade, set lines to TRUE when you want to do that by linetype. |
colors |
When highlighting a clade, set colors to TRUE when you want to do that by color. |
A ggtree
object which
can be edited using the ggtree-commands
.
G Yu, DK Smith, H Zhu, Y Guan, TTY Lam*. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data. Methods in Ecology and Evolution. 2017, 8(1):28-36. doi: 10.1111/2041-210X.12628.
The ggtree cookbook by Guangchuang Yu.
#this code requires other packages:
#library(ggtree)
#library(ggplot2)
#load example data from bactMAP examples (https://veeninglab.com/f/example_datasets.zip)
load("ssbB_phylos.Rda")
load("ssbB_meanfluo.Rda")
myTreeData <- ssbB_phylos
myFluoData <- ssbB_meanfluo
#plot Tree with attributes
plotTreeBasic(myTreeData, myFluoData) +
geom_point(aes(x=x-branch.length, color=fluormean), size=6) + #same as before, but different dot size
geom_tippoint(aes(color=fluormean_D), size=6) + #added tip points, different dot size
geom_label(aes(x=x-branch.length, label=label), color=NA, fill="white", alpha=0.5, size=1) +
#I also make a seethrough background label so you can see the text over the colored dots
geom_text(aes(x=x-branch.length, label=label), size=3) +
scale_color_viridis_c(option="magma") + #add different color scale, for fun
theme(legend.position="right") + #add legend
coord_flip()