View source: R/fit_periodic_loess.R
| fit_periodic_loess | R Documentation | 
The function will fit a loess line using cell cycle position and other variables, such as expression levels of a gene or log-transformed totalUMIs numbers. The circular nature of cell cycle position is taken into account by making 3 copies inside the function. For convenience, the function will also return a scatter plot with fitted line if needed.
theta.v | 
 The cell cycle position - a numeric vector with range between 0 to 2pi.  | 
y | 
 The response variable - a numeric vector with the same length as   | 
span | 
 The parameter α which controls the degree of smoothing. See   | 
length.out | 
 The number of data points on the fitted lines to be output in the prediction data.frame. Default: 200  | 
plot | 
 If   | 
fig.title | 
 The title of the figure. Default: NULL  | 
point.size | 
 The size of the point in scatter plot used by   | 
point.alpha | 
 The alpha value (transparency) of the point in scatter plot used by   | 
line.size | 
 The size of the fitted line, used by   | 
line.alpha | 
 The alpha value (transparency) of the fitted line, used by   | 
color.vars | 
 Optional. A vector of categorical variable of the same length of   | 
color.name | 
 The name of the color variables. Used as the name for legend. Default: NULL  | 
x_lab | 
 Title of x-axis. Default: "θ"  | 
y_lab | 
 Title of y-axis. Default: "y"  | 
hue.colors | 
 The string vector gives custom colors. If not given, the default   | 
... | 
 Other arguments input to   | 
This function fit a normal loess line, but take the circularity of cell cycle position into account by making theta.v 3 periods
(c(theta.v - 2 * pi, theta.v, theta.v + 2 * pi)) and repeating y 3 times. Only the fitted values corresponding to original theta.v
will be returned. For convenience, the function will also return a scatter plot with fitted line if needed. 
Or user can use pred.df to visualize the loess line themselves.
A list with the following elements:
fitted - The fitted vaues on the loess line. A vector of the length of y.
residual - The residual values from the fitted loess line, i.e. y - y.fit. A vector of the length of y.
 pred.df - The prediction data.frame by uniformly sampling theta from 0 - 2*pi. Names of variables: x and y. The number of rows equals to length.out.
loess.o - The fitted loess object.
rsquared - The coefficient of determination R2. Calculated as 1 - residual sum of squares / the total sum of squares.
 fig - When plot is TRUE, a ggplot scatter plot object will be returned with other items.
Shijie C. Zheng
estimate_cycle_position, for inferring cell cycle position.
data(neurosphere_example, package = "tricycle") neurosphere_example <- estimate_cycle_position(neurosphere_example) top2a.idx <- which(rowData(neurosphere_example)$Gene == "Top2a") fit.l <- fit_periodic_loess(neurosphere_example$tricyclePosition, assay(neurosphere_example, "logcounts")[top2a.idx, ], plot = TRUE) fit.l$fig
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.