Skip to contents

This function computes the correlation of expression of a set of genes for each cell type in the input data. The input data can be of three types: 'scrna', 'spatial_p' or 'spatial_t'. If the genes parameter is not provided by the user, the top variable genes will be selected based on the num_top_gene parameter (defaults to 100).

Usage

run_gene_cor_celltype(
  data,
  type = "scrna",
  genes = NULL,
  num_top_gene = NULL,
  ncores = 1
)

Arguments

data

A list object containing data matrix and celltype and sample vector.

type

The type of dataset, either "scrna", "spatial_t", or "spatial_p".

genes

Optional dataframe with 2 columns: 'marker' and 'celltype'. The 'marker' column should contain the genes of interest (e.g. 'S100A11', 'CCL4'), and the 'celltype' column should contain the celltype that the gene expression is to be computed from (e.g. 'CD8', 'B cells'). If not provided, the top variable genes will be used based on the num_top_gene parameter.

num_top_gene

Number of top genes to use when genes is not provided. Defaults to 5.

ncores

Number of cores for parallel processing.

Value

a dataframe of samples x features. The features are in the form of gene 1 vs gene 2 cell type a , gene 1 vs gene 3 cell type b ... etc, with the numbers representing the correlation of the two given genes in the given cell type.

Examples


utils::data("example_scrnaseq" , package = "scFeatures")
data <- example_scrnaseq[1:50, 1:20]
celltype <- data$celltype
sample <- data$sample
data <- data@assays$RNA@data

alldata <- scFeatures:::formatData(data = data, celltype = celltype, sample = sample )

feature_gene_cor_celltype <- run_gene_cor_celltype(
   alldata,
   type = "scrna", num_top_gene = 5, ncores = 1
 )
#> Warning: x or y has vectors with zero standard deviation; consider setting use_nan = TRUE to set these values to NaN or use_nan = FALSE to suppress this warning
#> Warning: x or y has vectors with zero standard deviation; consider setting use_nan = TRUE to set these values to NaN or use_nan = FALSE to suppress this warning
#> Warning: x or y has vectors with zero standard deviation; consider setting use_nan = TRUE to set these values to NaN or use_nan = FALSE to suppress this warning
#> Warning: x or y has vectors with zero standard deviation; consider setting use_nan = TRUE to set these values to NaN or use_nan = FALSE to suppress this warning