jj_summarize_nearest_neighbour_data: smooth values using nearest neighbours

View source: R/jj_smooth_over_neighbours.R

jj_summarize_nearest_neighbour_dataR Documentation

smooth values using nearest neighbours

Description

smooth values in a data.frame by taking the mean (numeric columns) or mode (character columns) among the k nearest neighbours for each cell (row)

Usage

jj_summarize_nearest_neighbour_data(dr_df, reduction_df, k = 30)

Arguments

dr_df

data.frame to smooth values over

reduction_df

data.frame with embeddings from dimensionality reduction (same nrow as dr_df)

k

number of nearest neighbours to smooth over for each cell

Examples

emb_df = Embeddings(pbmc_small, 'tsne')
meta_df = pbmc_small[[]]
res = jj_summarize_nearest_neighbour_data(dr_df = meta_df, reduction_df = emb_df, k = 5)
pbmc_small$nCount_RNA_smoothed = res$nCount_RNA
pbmc_small$groups_smoothed = res$groups
jj_arrange_ggplots(jj_plot_features(pbmc_small, reduction = 'tsne', 
                                   meta_features = c('nCount_RNA','nCount_RNA_smoothed', 'groups', 'groups_smoothed'), 
                                   pt.size = 2, return_gg_object = T))

mathosi/jj documentation built on Feb. 25, 2024, 2:29 p.m.