library(knitr) # knitr::opts_chunk$set(cache = TRUE, warning = FALSE, # message = FALSE, cache.lazy = FALSE) library(dplyr) library(tidyr) library(tibble) library(magrittr) library(ggplot2) library(ggrepel) library(tidybulk) library(tidySummarizedExperiment) my_theme = theme_bw() + theme( panel.border = element_blank(), axis.line = element_line(), panel.grid.major = element_line(size = 0.2), panel.grid.minor = element_line(size = 0.1), text = element_text(size=12), legend.position="bottom", aspect.ratio=1, strip.background = element_blank(), axis.title.x = element_text(margin = margin(t = 10, r = 10, b = 10, l = 10)), axis.title.y = element_text(margin = margin(t = 10, r = 10, b = 10, l = 10)) ) tibble_counts = tidybulk::se_mini %>% tidybulk() %>% as_tibble()
In this article we show some examples of the differences in coding between tidybulk/tidyverse and base R. We noted a decrease > 10x of assignments and a decrease of > 2x of line numbers.
tidybulk
tibble.tt = se_mini
transcripts
counts
variable transcripts
We may want to identify and filter variable transcripts.
dimensions
tt.norm.PCA = tt.norm %>% reduce_dimensions(method="PCA", .dims = 2)
count_m_log = log(count_m + 1) pc = count_m_log %>% prcomp(scale = TRUE) variance = pc$sdev^2 variance = (variance / sum(variance))[1:6] pc$cell_type = counts[ match(counts$sample, rownames(pc)), "Cell type" ]
tt.norm.tSNE = breast_tcga_mini_SE %>% tidybulk( sample, ens, count_scaled) %>% identify_abundant() %>% reduce_dimensions( method = "tSNE", perplexity=10, pca_scale =TRUE )
count_m_log = log(count_m + 1) tsne = Rtsne::Rtsne( t(count_m_log), perplexity=10, pca_scale =TRUE )$Y tsne$cell_type = tibble_counts[ match(tibble_counts$sample, rownames(tsne)), "Cell type" ]
dimensions
differential abundance
counts
Cell type composition
samples
Matrix package (v1.3-3) causes an error with Seurat::FindNeighbors used in this method. We are trying to solve this issue. At the moment this option in unaviable.
redundant
transcriptsheatmap
density plot
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.