batch_pca: Produce PCA in batch

View source: R/batch_PCA.R

batch_pcaR Documentation

Produce PCA in batch

Description

The goal of this function is to take a csv file or a data.frame describing all the PCA to produce and launch them in batches.

Usage

batch_pca(
  pca_infos,
  txi,
  metadata = NULL,
  outdir = NULL,
  r_objects = NULL,
  force = FALSE,
  cores = 1
)

Arguments

pca_infos

A csv file or a data.frame describing the PCA to produce.

txi

The txi object returned by the import_kallisto function.

outdir

The directory where to save PCA in pdf format. If NULL, the plots won't be saved as pdf. The files will be saved as <outdir>/<id_plot>.pdf. Default: NULL.

r_objects

The directory where to save PCA in rds format. If NULL, the plots won't be saved as rds files. The files will be saved as <r_objects>/<id_plot>.rds. Default: NULL.

force

Should the files be re-created if they already exists? Default: FALSE.

cores

Number of cores for the DE analysis. Default: 1

metatada

The metadata to add to the coordinate table to add color or shape with the results and the plot_pca function. If there is no metadata available, keep the default value of NULL. Value can either be a csv file or a data.frame. Default: NULL.

Details

The table may contain the following columns, in no specific order: * id_plot: unique identifier for this graph. Mandatory * group: column from the metadata file to subset the txi. If value is NA, all the samples will be used in the PCA. If value is not NA, group_val value must not be NA either. If NA, group_val must also be NA. Default: NA * group_val: Value in the group column to use in current PCA. If group is NA, group_val must also be NA. If group is not NA, group_val must be a valid column name from the metadata table. Default: NA * use_normalisation: "none", "ruvg" or "combat" (txi must be produced in consequence). Default: "none" * min_counts: Mean values of counts (TPM, ruvg or combat) to keep gene for PCA. Default: 5 * id_metadata: Column in metadata table that contains the sample names. Must be present in the colnames of the metadata table. Default: NA * size: The point size. Default: 3 * shape: The column in the metadata file to use to define shapes. Default: NA * color: The column in the metadata file to use to define colors. Default: NA * title: The title of the PCA. Default: NA * legend.position: "left", "right", "top" or "bottom". Default: "right" * legend.box: "horizontal" or "vertical". Default: "vertical" * show_names: Show sample names on PCA? Default: TRUE

Only the id_plot is mandatory. This value is used to name the PCA plots that are created by the batch_pca function and the output and r_objects filename.

If the other columns are absent, they will be automatically created and filled with their default values.

Value

Invisibly returns a list of all the ggplots.

Examples

pca_infos <- get_demo_pca_infos_file()
txi <- get_demo_txi(large = TRUE)
metadata <- get_demo_metadata_file()
gg_list <- batch_pca(pca_infos, txi, metadata)


CharlesJB/rnaseq documentation built on Oct. 17, 2023, 5:37 p.m.