Last updated: 2020-04-30

Checks: 7 0

Knit directory: MINTIE-paper-analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.6.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20200415) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version c4c3844. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/cache/
    Ignored:    data/.DS_Store
    Ignored:    data/salmon_out/
    Ignored:    data/simu/.DS_Store

Untracked files:
    Untracked:  data/leucegene/
    Untracked:  data/ref/tx2gene.txt.gz

Unstaged changes:
    Modified:   .gitignore

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/Leucegene_Gene_Expression.Rmd) and HTML (docs/Leucegene_Gene_Expression.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd c4c3844 Marek Cmero 2020-04-30 Added leucegene gene expression notebook

# util
library(data.table)
library(dplyr)
library(here)
library(stringr)

# plotting
library(ggplot2)
library(RColorBrewer)

# bioinformatics/stats helpers
library(tximport)
library(limma)
library(matrixStats)
source(here("code/plot.R"))
options(stringsAsFactors = FALSE)

Leucegene Gene Expression

Here we generate a PCA plot for all the Leucegene samples used in the MINTIE paper KMT2A-PTD and normal sample analyses, and perform a few small expression analyses presented in the paper.

salmon_dir <- here("data/salmon_out")

# construct list of quant.sf files 
quant_files <- list.files(salmon_dir) %>% 
                    str_c(salmon_dir, ., "quant.sf", sep = "/")

# transcript > gene reference file for CHESS
tx2gene <- read.delim(gzfile(here("data/ref/tx2gene.txt.gz")))

# import quant files
txi <- tximport(quant_files,
                type = "salmon",
                countsFromAbundance = "lengthScaledTPM",
                tx2gene = tx2gene,
                ignoreTxVersion = FALSE)

# load sample info
celltype <- read.delim(here("data/leucegene/celltypes_info.tsv"))
kmt2a_samples <- read.delim(here("data/leucegene/KMT2A-PTD_samples.txt"), header = FALSE)$V1
aml_controls <- read.delim(here("data/leucegene/selected_13_CBF_AML_controls.txt"), header = FALSE)$V1
nup_samples <- read.delim(here("data/leucegene/NUP98-NSD1_samples.txt"), header = FALSE)$V1

# reduced normal control set (used in KMT2A-PTD analysis)
s1 <- celltype$SRX_ID[celltype$cell_type == "Total white blood cells"][1]
s2 <- celltype$SRX_ID[celltype$cell_type == "Monocytes"][1]
s3 <- celltype$SRX_ID[celltype$cell_type == "Granulocytes"][1]
reduced_normal_controls <- c(s1, s2, s3)

PCA plot

PCA of gene expression derived from Salmon quantification for Leucegene KMT2A-PTD and normals. Normal samples used as controls in the reduced set of controls are circled.

# get counts matrix
counts <- txi$counts
colnames(counts) <- list.files(salmon_dir)

# variance stabilised, log2 CPM transformation
ve <- voom(counts)$E

# select 500 most variable genes
select <- order(rowVars(ve), decreasing = T)[1:500]

# perform PCA amd select first two components
pr <- prcomp(ve[select,])
pc <- data.frame(pr$rotation[,1:2])
pc$sample <- rownames(pc)

# attach labels
pc <- left_join(pc, celltype, by = c("sample" = "SRX_ID"))
pc$cell_type[pc$sample %in% kmt2a_samples] <- "KMT2A-PTD"
pc$cell_type[pc$sample %in% nup_samples] <- "NUP98-NSD1"
pc$cell_type[pc$sample %in% aml_controls] <- "CBF AML controls"
pc <- pc[!is.na(pc$cell_type),]

# make colour mappings
cols <- brewer.pal(8, "RdBu")
names(cols) <- c("KMT2A-PTD",
                 "CBF AML controls",
                 "Granulocytes",
                 "Monocytes",
                 "Total white blood cells",
                 "T-cells",
                 "B-cells")
pc$cell_type <- factor(pc$cell_type, levels = names(cols))

# plot
ggplot(pc, aes(PC1, PC2, colour = cell_type)) +
    geom_point(size = 2.5) +
    theme_bw() +
    scale_color_manual(values = cols) +
    theme(legend.title = element_blank()) +
    geom_point(data = pc[pc$sample %in% reduced_normal_controls,],
               shape = 1, size = 5, fill = NA, colour = 'darkgrey')


sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.14.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] matrixStats_0.54.0 limma_3.38.3       tximport_1.10.1   
[4] RColorBrewer_1.1-2 ggplot2_3.1.0      stringr_1.4.0     
[7] here_0.1           dplyr_0.8.1        data.table_1.12.0 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1       compiler_3.5.1   pillar_1.3.1     later_1.0.0     
 [5] git2r_0.26.1     plyr_1.8.4       workflowr_1.6.1  tools_3.5.1     
 [9] digest_0.6.18    jsonlite_1.6     evaluate_0.13    tibble_2.1.1    
[13] gtable_0.3.0     pkgconfig_2.0.2  rlang_0.4.2      yaml_2.2.0      
[17] xfun_0.5         withr_2.1.2      knitr_1.22       hms_0.4.2       
[21] fs_1.2.7         rprojroot_1.3-2  grid_3.5.1       tidyselect_0.2.5
[25] glue_1.3.1       R6_2.4.0         rmarkdown_1.12   readr_1.3.1     
[29] purrr_0.3.2      magrittr_1.5     codetools_0.2-16 backports_1.1.3 
[33] scales_1.0.0     promises_1.1.0   htmltools_0.3.6  assertthat_0.2.1
[37] colorspace_1.4-1 httpuv_1.5.2     labeling_0.3     stringi_1.4.3   
[41] lazyeval_0.2.2   munsell_0.5.0    crayon_1.3.4