knitr::opts_chunk$set( collapse = TRUE, echo = TRUE, warning = FALSE, message = FALSE )
library(CellSurvAssay)
CellSurvAssay consists of a couple of tools that can be used to perform Clonogenic Survival Analysis in R very easily and efficiently. These two tools are:
CellSurvAssay R package: This helps even beginner R users to perform the analysis in R, while maintaining the flexibility of a package.
CellSurvAssay Shiny app: This is a web application that helps users with no experience in R to perform the analysis, in R. The app is based on the CellSurvAssay R package and can be accessed here.
This document is the vignette that accompanies with the R package, and describes comprehensively how the package works and how it can be used to perform the analysis. For details on the Shiny app, please access it and refer to its Help pages. For more details on both of these tools and methodologies, please refer to (cite our paper).
ggplot()
to plot the cell survival curves, and builds better quality figures than other available R packages,# if installing from Bioconductor # install BiocManager, if required if (!require("BiocManager", quietly = TRUE)) install.packages("BiocManager") # install CellSurvAssay BiocManager::install("CellSurvAssay") # load CellSurvAssay in R library(CellSurvAssay) # if installing from GitHub # install devtools, if required if(!require(devtools)) { install.packages("devtools") library(devtools) } # install CellSurvAssay install_github("pickeringlab/CellSurvAssay", build_vignettes = TRUE, dependencies = TRUE) # load CellSurvAssay in R memory library(CellSurvAssay)
browseVignettes("CellSurvAssay")
importData()
helps import the data set. Its a simple helper function aimed for aiding beginner R users, and other importing functions can be used as well instead of this.datatab
to the data, but any other name can be used as well.datatab <- importData("path/to/file", "type of file")
filetype
is a requirement, as shown below:datatab <- importData("path/to/file.xlsx") #for an excel file datatab <- importData("path/to/file.csv", filetype = "csv") #for a csv file datatab <- importData("path/to/file.tsv", filetype = "tsv") #for a tsv file
#for a '|' delimited file datatab <- importData("path/to/file", filetype = "txt", separator = "|") #for a tab delimited file datatab <- importData("path/to/file", filetype = "txt", separator = "\t")
datatab <- CASP8_data
Additional arguments can be used with importData()
as well, just like the read_csv, read_tsv & read_delim functions of the readr package, or the read_excel function of the readxl package.
Below are a couple of examples of additional arguments that can be used to import a data set using importData()
:
#to skip the first couple of rows datatab <- importData("path/to/file.xlsx", skip = 2) #to tell R that missing values are denoted by "-" in the data being imported datatab <- importData("path/to/file.xlsx", na = "-")
datatab
is chosen for the imported data set, that name must be used in the downstream analysis.View(datatab)
The linear-quadratic model depicts the effect of radiation or other insulting agent on cell survival. It's given by: $$ S = S(D)/S(0) = e^{- \alpha D - \beta D^2} $$
Here, cell survival S is a function of dose D of the insulting agent to which the cells are exposed. S(0) is the plating efficiency, the surviving fraction of untreated or unirradiated cells, and S(D) is that of treated cells. $\alpha$ and $\beta$ are parameters that describe the cell's radiosensitivity.
Typically, S(0) is considered fixed and kept on the left side of the equation. However, CFAssay treats colonies from untreated cells as random observations, similar to colonies from treated cells, and keeps S(0) on the right side of the equation. Moreover, CFAssay formulates the equation differently and reverses the signs, resulting in the following equation: $$ S = S(D) = e^{c + \alpha D + \beta D^2} $$
$c=\log {S(0)}$ is the intercept here and varies between different experiments.
CellSurvAssay fits the linear quadratic model similar to CFAssay. The lqmodelFit()
function helps fit the linear quadratic model for any cell type present in the imported data.
Within the parentheses, first enter the name of the data set given by you, and then, within quotes, the cell type for which the model is to be fit.
lqmodelFit(datatab, "shCASP8-N")
(method = “ls”)
and a weighted LS method described by Franken et al. (method = “franken”)
are also present for comparison.lqmodelFit(datatab, "shCASP8-N", method = "ls") #least squares method lqmodelFit(datatab, "shCASP8-N", method = "franken") #franken method
(PEmethod = “fit”)
, the option for implementing the conventional normalization method (PEmethod = “fix”)
is present as well for evaluation.lqmodelFit(datatab, "shCASP8-N", PEmethod = "fix")
plotCSCurve()
and ggplotCSCurve()
.ggplot()
function of R to plot the curves, allowing all the customizations and better graphics. It also allows to easily download the figures plotted in the users' own specifications. Both the functions are described below.plotCSCurve()
plotCSCurve()
helps plot both individual and multiple curves. Below is the simplest way to plot a curve of a single cell type.plotCSCurve(datatab, "control-B")
plotCSCurve()
will help you plot multiple curves. Instead of entering a single cell type, just enter all the cell types for which the curves are required.plotCSCurve(datatab, "shCASP8-NT", "shCASP8-B", "shCASP8-B+Z", "shCASP8-B+Z+N")
col = "name_of_color"
for a single curve and col = c("name_of_color_1", "name_of_color_2",...)
for multiple curves. The names of colors accepted in R can be found here or here. Choose your favorite ones!xlim
and ylim
can be used to changed the default limits of x and y axes respectively. E.g. ylim = c(0.1, 1)
will change the start of y-axis to 0.1 and the end to 1.xlab
and ylab
can be used to change the default labels of x and y axes respectively. E.g. xlab = "X axis"
will change the default label of x-axis to "X axis".title = "Title of the plot"
will give a title to the plot.pch = shape_number
or pch = "shape_character
can change the shape of the points in the curve. You can either enter an integer, or a character within quotes, as mentioned here in the section "pch symbols list".plotCSCurve(datatab, "shCASP8-NT", "shCASP8-B", "shCASP8-B+Z", "shCASP8-B+Z+N", col = c("red", "blue", "darkgreen", "steelblue"), pch = 4, ylim = c(0.01, 1), xlab = "X-axis", ylab = "Y-axis", title = "Cell Survival Curves")
plotCSCurve(datatab, "control-B", method = "franken", PEmethod = "fix")
ggplotCSCurve()
ggplotCSCurve()
function plots them using ggplot()
.ggplotCSCurve()
plots, the arguments are exactly similar to the plotCSCurve()
function, for both single and multiple curves.ggplotCSCurve(datatab, "shCASP8-NT")
ggplotCSCurve(datatab, "shCASP8-NT", "shCASP8-B", "shCASP8-B+Z", "shCASP8-B+Z+N")
colors
argument lets you change the default colors of the curves. It must be passed similarly as the col
argument of plotCSCurve()
: colors = "name_of_color"
for a single curve and colors = c("name_of_color_1", "name_of_color_2",...)
for multiple curves. The names of colors accepted in R can be found here or here. Choose your favorite ones! Note: The number of colors chosen should be equal to or more than the number of cell types passed as arguments. If no colors are chosen by the user, the function chooses them by random and they might change with each plotting. Also, the sequence in which the colors are entered is matched with the sequence of the cell types. So, the first color entered is assigned to the first cell type, and so on.title
gives a title to the plot. Default is ""
. E.g. title = "Cell Survival Curves"
provides a title to the plot "Cell Survival Curves".title_size
accepts an integer and changes the font size of the title. E.g. title_size = 12
.title_color
changes the font color of the title. E.g. title_color = "red"
.title_face
changes the font face of the title. Accepted arguments are "plain"
/"bold"
/"italic"
/"bold.italic"
. Default is "plain"
. E.g. title_face = "bold.italic"
.title_align
changes the alignment/justification of the plot title. Accepts "left
, "center"
, and "right"
. Default is "center"
.subtitle = "Subtitle"
gives a subtitle to the plot. The font size, color, face, and alignment can be changed by sub_size
, sub_color
, sub_face
, and sub_align
respectively, similar to the title of the plot.xlab
and ylab
can be used to change the default labels of x and y axes respectively. E.g. xlab = "X axis"
will change the default label of x-axis to "X axis". The default label for X-axis is "Dose(Gy)
, and that for the Y-axis is "Survivng Fraction"
. The font size, color, and face of the x-axis label can be changed by xlab_size
, xlab_color
, and xlab_face
respectively, and that of the y-axis label can be changed by ylab_size
, ylab_color
, and ylab_face
respectively, similar to the title of the plot. The default values for these, both for the X and Y axes, are 16
, "black"
, and "bold"
.legend_pos
can be used to control the position of the legend. Default is "inside"
, which puts the legend in the bottom left of the figure. If "outside'
, then puts it outside on the right of the figure, and if "none"
, then removes it.legend_title
adds a title for the legend; default is ""
. E.g. legend_title = "Cell types"
changes the legend title to "Cell types". The font size, color, face, and alignment of the legend title can be changed by ltitle_size
, ltitle_color
, ltitle_face
, and ltitle_align
respectively, similar to the plot title. The default values for these are 20
, "black"
, "bold"
, and "left"
respectively.ltext_size
, ltext_color
, and ltext_face
change the font size, color, and face of the texts in the legend respectively. The default values are 18
, "black"
, and "bold"
.xtext_size
, xtext_color
, and xtext_face
change the font size, color, and face of the x-axis tick labels respectively. The default values are 14
, "black"
, and "bold"
.ytext_size
, ytext_color
, and ytext_face
change the font size, color, and face of the y-axis tick labels respectively. The default values are 14
, "black"
, and "bold"
.point_shape
accepts an integer or character similarly as pch
in plotCSCurve()
to change the shape of the points in the plot. You can either enter an integer, or a character within quotes, as mentioned here in the section "pch symbols list". Default is 16
.point_size
accepts an integer and determines the size of the points in the plot. Default is 3.5
.curve_type
and segment_type
accept integers, or characters within quotes, and determine the types of line used to plot the curve and the vertical line segment respectively. The type of lines accepted by R can be found here, under the section "Line types". The default values of both are 1
.curve_width
and segment_width
accept numbers and determine the widths of the curve and the vertical line segment respectively. The default values are 1.5
and 1
respectively.theme
will determine the theme of the plot. The theme should be entered in the following manner: theme = package::theme_name()
. A good list of themes can be found here. The default value is ggplot2::theme_bw()
.ybreaks
accept a vector of numbers denoting the breaks in y-axis: ybreaks = c(break1, break2, ...)
. These list of breaks or ticks will appear on the plot. The default values are chosen automatically by ggplot()
. Plots with same ybreaks
and ylim
are easier to compare.ylim
can be used to changed the default limits of x and y axes respectively. E.g. ylim = c(0.1, 1)
will change the start of y-axis to 0.1 and the end to 1. The default values are chosen automatically by ggplot()
. Plots with same ybreaks
and ylim
are easier to compare.save = "yes"
saves the plot in the specified path, format, and size. Default is "no"
.save_path
can be used to specify the path where the plot is to be saved. E.g. save_path = "C:/User1/Desktop"
. If nothing is specified, the plot is saved in the current working directory obtained by getwd()
.save_filename
can be used to specify the desired file name and extension of the plot to be saved. Accepts most common extensions, including ".pdf"
, ".jpeg"
, and ".png"
. Default is "myplot.pdf
.plot_height
and plot_width
is used to specify the size of the plot to be saved. units
allows to specify the unit of the measurements, and accepts "in"
, "cm"
, "mm"
, or "px"
. The default for the height is 4
, width is 5
, and units is "in"
.ggplotCSCurve(datatab, "shCASP8-NT", "shCASP8-B", "shCASP8-B+Z", "shCASP8-B+Z+N", colors = c("red", "blue", "darkgreen", "steelblue"), title = "Cell Survival Curves", title_size = 20, title_color = "darkgreen", title_align = "left", subtitle = "CellSurvAssay", sub_color = "steelblue", sub_align = "left", xlab = "X-axis", xlab_color = "red", xlab_size = 14, xlab_face = "bold.italic", ylab = "Y-axis", ylab_color = "red", ylab_size = 14, ylab_face = "bold.italic", xtext_color = "purple", ytext_color = "purple", legend_title = "Cell types", ltitle_size = 15, legend_back = "gray", legend_border = "black", legend_border_width = 0.5, ltitle_align = "center", point_shape = 15, point_size = 1, segment_width = 1, segment_type = 1, curve_width = 1.1, curve_type = 1, theme = ggplot2::theme_test())
ggplotCSCurve(datatab, "shCASP8-NT", "shCASP8-B", "shCASP8-B+Z", "shCASP8-B+Z+N", save = "Yes", plot_height = 4, plot_width = 5, units = "in", save_path = "C:/User1/desktop", save_filename = "Plot.pdf")
ggplotCSCurve()
plotsggplot()
allows users to add any number of layers to a ggplot
object. This property can be used as an advantage to add customization to a ggplotCSCurve()
plot.legend_pos = "none"
to remove the legend, we can do the same in the following manner:library(ggplot2) ggplotCSCurve(datatab, "shCASP8-NT", "shCASP8-B", "shCASP8-B+Z", "shCASP8-B+Z+N") + theme(legend.position = "none")
ggplotCSCurve()
.ggplot()
, and the ggplot2
package should be loaded in memory using library(ggplot2)
as above.compareCurves()
function helps us statistically compare two curves. It prints the ANOVA results.compareCurves(datatab, "shCASP8-N", "shCASP8-B+Z+N")
calculateDER()
calculates the Dose Enhancement Ratio.calculateDER(datatab, "shCASP8-NT", "shCASP8-N", 0.25)
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.