knitr::opts_chunk$set(echo = TRUE)

R Markdown

Makes plots to evaluate deconvolution methods on mixture from scRNA-seq data

Obtain trueH, trueW and resultH, resultW from each deconvolution method

# Obtains trueW, trueH from exp2.RData
load("~/rnaGinesis/data/Dataset_ResampledSingleCell.RData")
trueW <- Dataset_ResampledSingleCell$trueW
trueH <- Dataset_ResampledSingleCell$trueH

# Obtains resultW, resultH from NMF and rearranges them to match trueW, trueH ordering
load("~/rnaGinesis/data/Dataset_ResampledSingleCell.NMF.result.RData")

Dataset_ResampledSingleCell.NMF <- rearrange(Dataset_ResampledSingleCell.NMF, Dataset_ResampledSingleCell)

resultW.NMF <- Dataset_ResampledSingleCell.NMF[[1]]
resultH.NMF <- Dataset_ResampledSingleCell.NMF[[2]]

Creates H.RMSE with RMSE between true props and estimated props across all samples for each deconvolution method

# Normalizes resultH so that proportions sum to 1
resultH.NMF <- apply(resultH.NMF, 2, FUN = sum_to_1)

# Do the same for the second deconvolution method

# Obtains RMSE for each sample between true proportions and estimated proportions
H.RMSE <- makeH.RMSE(trueH, resultH.NMF, resultH.NMF, "NMF", "TBD_Method")

Graphs violin plot with H.RMSE values from each deconvolution method

# melts H.RMSE into dataframe with two variables and H.RMSE across all samples for each deconvolution method 
mydf <- reshape2::melt(H.RMSE)
mydf <- mydf[,-1]
names(mydf) <- c("method", "H_RMSE") 

# plots H.RMSE between true proportions and estimated proportions in each sample based on deconvolution method
# make jitter reproduceable
set.seed(1234)
p <- ggplot2::ggplot(data = mydf, ggplot2::aes(y = H_RMSE, x= method, fill = method))
p <- p + ggplot2::geom_violin()
p <- p + ggplot2::geom_jitter(width = 0.1, height = 0) #+ ggplot2::ylim(0,1) 
p <- p + ggplot2::labs(title="Violin Plots of Root Mean Squared Error (RMSE) for Proportions",
                       x = "Deconvolution Method",
                       y = "H_RMSE")
p <- p + ggplot2::theme(axis.title.x = ggplot2::element_text(size = 40)) 
p <- p +  ggplot2::theme(axis.title.y = ggplot2::element_text(size = 40)) 
p <- p +  ggplot2::theme(axis.text = ggplot2::element_text(size=30))

print(p)

Creates W.COSDIST with COSDIST between true cell-type specific gene expression profiles and estimated gene expression profiles for each sample

W.COSDIST <- makeW_COSDIST(trueW, resultW.NMF, resultW.NMF, "NFM", "TBD_Method")

Graphs violin plots with W.COSDIST values from each deconvolution method

# melts W.COSDIST into dataframe with two variables and W.COSDIST across all samples for each deconvolution method 
mydf2 <- reshape2::melt(W.COSDIST)
mydf2 <- mydf2[,-1]

names(mydf2) <- c("method", "W_COSDIST") 

# plots W.COSDIST between true W and estimated W in each sample based on deconvolution method
# make jitter reproduceable
set.seed(1234)
p2 <- ggplot2::ggplot(data = mydf2, ggplot2::aes(y = W_COSDIST, x= method, fill = method))
p2 <- p2 + ggplot2::geom_violin()
p2 <- p2 + ggplot2::geom_jitter(width = 0.1, height = 0) #+ ggplot2::ylim(0,1.5) 
p2 <- p2 + ggplot2::labs(title="Violin Plots of Cosine Distance (COSDIST) for Gene Expression",x = "Deconvolution Method", y = "W_COSDIST") + ggplot2::theme(axis.title.x = ggplot2::element_text(size = 40)) + ggplot2::theme(axis.title.y = ggplot2::element_text(size = 40)) + ggplot2::theme(axis.text=ggplot2::element_text(size=30))
print(p2)


ayurovsky/rnaGinesis documentation built on Dec. 19, 2021, 6:36 a.m.