This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select <- dplyr::select | |
mutate <- dplyr::mutate | |
arrange <- dplyr::arrange | |
rename <- dplyr::rename |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Plot a CNV heatmap | |
#' \code{cnv_data} must have the following columns: | |
#' | |
#' - start (start position of each region) | |
#' - chr (chromosome) | |
#' - single_cell_id (id of each cell) | |
#' - clone (clone to which each cell is assigned) | |
#' - copy_number (copy number of each clone in region) | |
#' | |
#' @export |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export PATH=$PATH:/Applications/RStudio.app/Contents/MacOS/pandoc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(limma) | |
library(tidyverse) | |
dge <- DGEList(counts(sce_de)) | |
dge <- calcNormFactors(dge) | |
design <- model.matrix(~ (dbz_cluster_str == "Unknown"), colData(sce_de)) # Your design matrix here | |
v <- voom(dge, design, plot = TRUE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(biomaRt) | |
ensembl <- useMart("ensembl") | |
ensembl <- useDataset("hsapiens_gene_ensembl", mart=ensembl) | |
bm <- getBM(attributes = c("ensembl_gene_id", "hgnc_symbol"), | |
filters = c("ensembl_gene_id"), | |
values = ensembl_gene_ids, | |
mart = ensembl) %>% | |
as_data_frame() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' These functions round an input string 'x' to a desired | |
#' number of decimal places | |
round1 <- function(x) format(round(x, 1), nsmall = 1) | |
round2 <- function(x) format(round(x, 2), nsmall = 2) | |
roundn <- function(x, n = 2) format(round(x, n), nsmall = n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Nice colour palette for visualising copy number profiles | |
# inspired by DLP paper | |
cnv_cols <- c("0" = "#deebf7", | |
"1" = "#9ecae1", | |
"2" = "grey80", | |
"3" = "#fdae6b", | |
"4" = "#e6550d") | |
# Factors for chromosomes | |
chr_levels <- c(as.character(1:23), "X", "Y") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(stringr) | |
library(ggplot2) | |
library(scran) | |
library(scater) | |
library(dplyr) | |
# Step 1: do the overdispersion analysis | |
sc2 <- sce[rowMeans(round(exprs(sce)) > 0) > 0, ] # Keep only genes that are expressed | |
is_ercc <- grepl("NA_ERCC", featureNames(sc2)) # Your ERCCs might be named differently to mine! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## You can show that the estimate of fg is wrong *only* | |
## when m_beta = 1 and m_c = 1 and xx = 1 and that in | |
## such a case it appears to overcount by 2, implying term 11 in the derivation is wrong | |
m_alpha <- 0 | |
s_alpha <- 1 | |
m_beta <- 1 | |
s_beta <- 1 | |
m_t <- 0 | |
s_t <- 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(stringr) | |
library(ggplot) | |
library(dplyr) | |
## Assuming "go" has columns "term" and "q_value" | |
go_top <- head(go, n = 10) | |
go_top$term <- str_to_title(go_top$term) | |
terms_sorted <- arrange(go_top, desc(q_value)) %>% .$term | |
go_top$term <- factor(go_top$term, levels = terms_sorted) |