This function computes the correlation of gene expression across samples. The user can specify the genes of interest, or let the function use the top variable genes by default. The function supports scRNA-seq, spatial proteomics, and spatial transcriptomics.
Arguments
- data
A list object containing
data
matrix andcelltype
andsample
vector.- type
The type of dataset, either "scrna", "spatial_t", or "spatial_p".
- genes
Default to NULL, in which case the top variable genes will be used. If provided by user, need to be in the format of a list containing the genes of interest, eg, genes <- c(GZMA", "GZMK", "CCR7", "RPL38" )
- num_top_gene
Number of top variable 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, gene 2 ... etc, with the numbers representing the proportion that the gene is expressed across all cells.
Examples
utils::data("example_scrnaseq" , package = "scFeatures")
data <- example_scrnaseq[1:100, 1:200]
celltype <- data$celltype
sample <- data$sample
data <- data@assays$RNA@data
alldata <- scFeatures:::formatData(data = data, celltype = celltype, sample = sample )
feature_gene_cor <- run_gene_cor(
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
#> 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
#> 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