# # - eval = FALSE ------------------------------------------------------------ # ## 试试http://如果不支持https:// url # (!requireNamespace(“BiocManager”,悄悄地= TRUE)) # install.packages (BiocManager) # BiocManager::安装(“scFeatureFilter ") ## ---- 消息= FALSE,警告= FALSE,崩溃= TRUE ----------------------------- 库(scFeatureFilter)图书馆(ggplot2)图书馆(cowplot) # # #多面板数据+不错的主题——崩溃= TRUE ----------------------------------------------------------- # 示例数据集包含的包:scData_hESC #过滤数据集通过一个函数调用:sc_feature_filter (scData_hESC ) ## ---- 崩溃= TRUE ----------------------------------------------------------- scData_hESC # #——崩溃= TRUE ----------------------------------------------------------- calculate_cvs (scData_hESC ) ## ---- 崩溃= TRUE ----------------------------------------------------------- 库(magrittr) #使用管% > % calculate_cvs (scData_hESC) % > % plot_mean_variance (colourByBin = FALSE) # #—崩溃= TRUE ----------------------------------------------------------- scData_hESC % > % calculate_cvs % > % define_top_genes (window_size = 100) % > % bin_scdata (window_size = 1000) # #——崩溃= TRUE ------------------------------------------------------------ myPlot < - scData_hESC % > % calculate_cvs % > % define_top_genes (window_size = 100) % > % bin_scdata (window_size = 1000) % > % plot_mean_variance (colourByBin = TRUE,density_color = "蓝色")myPlot # #——崩溃= TRUE ----------------------------------------------------------- myPlot + annotation_logticks(国= " l ") ## ---- 崩溃= TRUE ----------------------------------------------------------- corDistrib < - scData_hESC % > % calculate_cvs % > % define_top_genes (window_size = 100) % > % bin_scdata (window_size = 1000) % > % correlate_windows (n_random = 3 ) ## ---- 崩溃= TRUE ----------------------------------------------------------- 戈登主演< -correlations_to_densities (corDistrib absolute_cc = TRUE) plot_correlations_distributions(戈登主演,facet_ncol = 5) + scale_x_continuous(休息= c(0、0.5、1),标签= c(“0”,“0.5”,“1 ")) ## ---- 崩溃= TRUE ----------------------------------------------------------- 指标< - get_mean_median (corDistrib)指标plot_correlations_distributions(戈登主演,指标=指标,facet_ncol = 5) + scale_x_continuous(休息= c(0、0.5、1),标签= c(“0”,“0.5”,“1 ")) ## ---- 崩溃= TRUE ----------------------------------------------------------- plot_metric(指标、show_ctrl = FALSE show_threshold = FALSE ) ## ---- 崩溃= TRUE ----------------------------------------------------------- plot_metric(指标、show_ctrl = TRUE show_threshold = FALSE ) ## ---- 崩溃= TRUE ----------------------------------------------------------- plot_metric(指标、show_ctrl = TRUE show_threshold = TRUE,阈值= 2 ) ## ---- 崩溃= TRUE ----------------------------------------------------------- determine_bin_cutoff(指标、阈值= 2 ) ## ---- 崩溃= TRUE ----------------------------------------------------------- binned_data < - scData_hESC % > % calculate_cvs % > % define_top_genes (window_size = 100) % > % bin_scdata (window_size = 1000)指标< - correlate_windows (binned_data n_random = 3) % > % get_mean_median filtered_data < filter_expression_table (binned_data,bin_cutoff = determine_bin_cutoff(metrics)) dim(scData_hESC) dim(filtered_data) filtered_data ## ---- message=FALSE, warning=FALSE, collapse=TRUE----------------------------- library(singlecel实验)library(scRNAseq) #示例数据集sce_allen <- ReprocessedAllenData() # sce_allen是一个singlecel实验对象sce_allen filtered_allen <- sc_feature_filter(sce_allen,Sce_assay = "rsem_tpm") is.matrix(filtered_allen) # filtered_allen是一个tibble sce_filtered_allen <- sce_allen[rownames(filtered_allen), ] sce_filtered_allen ## ---- collapse=TRUE----------------------------------------------------------- plot_top_window_autocor(calculate_cvs(scData_hESC)) ## ---- collapse=TRUE----------------------------------------------------------- metrics_bigBins <- scData_hESC %>% calculate_cvs %>% define_top_genes(window_size = 100) %>% bin_scdata(window_size = 1000) %>% correlate_windows(n_random = 3) %>% get_mean_median metrics_smallBins <- scData_hESC %>% calculate_cvs %>% define_top_genes(window_size = 100) %>% bin_scdata(window_size = 500) %>% correlate_windows(n_random = 3) %>% get_mean_median plot_grid( plot_metric(metrics_bigBins) + labs(title = "1000 genes per bin"), plot_metric(metrics_smallBins) + labs(title = "500 genes per bin") )