From 83ff8d3ae2822f2bf3aedd90ced5fffc4b38a77a Mon Sep 17 00:00:00 2001 From: JunJunLao <1138976957@qq.com> Date: Wed, 5 Jun 2024 15:29:06 +0800 Subject: [PATCH] averageHeatmap on Seurat V5 [#43](https://github.com/junjunlab/scRNAtoolVis/issues/43) --- R/averageHeatmap.R | 1 + man/averageHeatmap.Rd | 122 +++++++++++++++++++++++++++++++++++++++ man/featureCornerAxes.Rd | 95 ++++++++++++++++++++++++++++++ 3 files changed, 218 insertions(+) create mode 100644 man/averageHeatmap.Rd create mode 100644 man/featureCornerAxes.Rd diff --git a/R/averageHeatmap.R b/R/averageHeatmap.R index b77d761..7dc69bb 100644 --- a/R/averageHeatmap.R +++ b/R/averageHeatmap.R @@ -85,6 +85,7 @@ averageHeatmap <- function( gene.order = NULL, ...) { # get cells mean gene expression + # check Seurat version if(utils::packageVersion("Seurat") > 4){ mean_gene_exp <- as.matrix( data.frame( diff --git a/man/averageHeatmap.Rd b/man/averageHeatmap.Rd new file mode 100644 index 0000000..544b6da --- /dev/null +++ b/man/averageHeatmap.Rd @@ -0,0 +1,122 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/averageHeatmap.R +\name{averageHeatmap} +\alias{averageHeatmap} +\title{Plot averaged gene expression cross cluster cells} +\usage{ +averageHeatmap( + object = NULL, + markerGene = NULL, + group.by = "ident", + assays = "RNA", + slot = "data", + htCol = c("#0099CC", "white", "#CC0033"), + colseed = 666, + htRange = c(-2, 0, 2), + annoCol = FALSE, + myanCol = NULL, + annoColType = "light", + annoColTypeAlpha = 0, + row_title = "Cluster top Marker genes", + clusterAnnoName = TRUE, + showRowNames = TRUE, + row_names_side = "left", + markGenes = NULL, + border = FALSE, + fontsize = 10, + column_names_rot = 45, + width = NULL, + height = NULL, + cluster.order = NULL, + cluster_columns = FALSE, + cluster_rows = FALSE, + gene.order = NULL, + ... +) +} +\arguments{ +\item{object}{object seurat object.} + +\item{markerGene}{Your marker genes.} + +\item{group.by}{Categories for grouping (e.g, ident, replicate, celltype). "ident" by default.} + +\item{assays}{Which assays to use. Default is "RNA" assays.} + +\item{slot}{Slot(s) to use. Default is "data".} + +\item{htCol}{Heatmap colors. Default is c("#0099CC", "white", "#CC0033").} + +\item{colseed}{Cluster annotation colors seed, these colors are produced randomly, so you can give a seed to assure produce same colors. Default is 666.} + +\item{htRange}{Heatmap values range. Default is c(-2, 0, 2).} + +\item{annoCol}{Whether use your own annotation clusters colors. Default is "FALSE".} + +\item{myanCol}{You can specify your own annotation clusters colors vectors. Default is "null".} + +\item{annoColType}{Cluster annotation colors type (bright, light, dark and random). Default is light.} + +\item{annoColTypeAlpha}{Cluster annotation colors transparency. Default is 0.} + +\item{row_title}{Heatmap row title. Default is "Cluster top Marker genes".} + +\item{clusterAnnoName}{Whether to add clsuetr column annotation name. Default is "TRUE".} + +\item{showRowNames}{whether to show rownames. Default is "TRUE".} + +\item{row_names_side}{Heatmap gene name side. Default is "left".} + +\item{markGenes}{Provide your tartget genes to mark on the plot. Default is "NULL".} + +\item{border}{Whether to shOw heatmap border. Default is "FALSE".} + +\item{fontsize}{Heatmap gene name fontsize. Default is 10.} + +\item{column_names_rot}{Cluster name rotation. Default is 45.} + +\item{width}{The heatmap body width. Default is "NULL".} + +\item{height}{The heatmap body height. Default is "NULL".} + +\item{cluster.order}{The cell clusters order. Default is "NULL".} + +\item{cluster_columns}{Whether cluster columns. Default is "FALSE".} + +\item{cluster_rows}{Whether cluster rows. Default is "FALSE".} + +\item{gene.order}{the gene orders for heatmap. Default is "NULL".} + +\item{...}{Other arguments passed with ComplexHeatmap::rowAnnotation and ComplexHeatmap::Heatmap.} +} +\value{ +Return a plot. +} +\description{ +Plot averaged gene expression cross cluster cells +} +\examples{ +httest <- system.file("extdata", "htdata.RDS", package = "scRNAtoolVis") +pbmc <- readRDS(httest) + +# load markergene +markergene <- system.file("extdata", "top5pbmc.markers.csv", package = "scRNAtoolVis") +markers <- read.table(markergene, sep = ",", header = TRUE) + +# plot +averageHeatmap( + object = pbmc, + markerGene = markers$gene +) + +# change color +averageHeatmap( + object = pbmc, + markerGene = markers$gene, + htCol = c("#339933", "#FFCC00", "#FF0033") +) + +} +\author{ +Junjun Lao +} diff --git a/man/featureCornerAxes.Rd b/man/featureCornerAxes.Rd new file mode 100644 index 0000000..d1bb1d3 --- /dev/null +++ b/man/featureCornerAxes.Rd @@ -0,0 +1,95 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/featureCornerAxes.R +\name{featureCornerAxes} +\alias{featureCornerAxes} +\title{Add corner axes on seurat UMAP/tSNE gene FeaturePlot function figures} +\arguments{ +\item{object}{object seurat object.} + +\item{reduction}{"string", reduction type (umap/tsne).} + +\item{features}{"string", the gene you want to plot.} + +\item{groupFacet}{"string", give the column name in seurat metadata to facet plot, if it is "NULL", facet plot only by gene.} + +\item{relLength}{"num", the corner axis line relative length to plot axis(0-1).} + +\item{relDist}{"num", the relative distance of corner axis label to axis.} + +\item{aspect.ratio}{"num", plot width and height ratio, default NULL.} + +\item{low}{"string", point color with low expression.} + +\item{high}{"string", point color with high expression.} + +\item{axes}{"string", show multiple corner axis or only one (mul/one), default "mul".} + +\item{legendPos}{"string", legend position same as ggplot theme function, default "right".} + +\item{stripCol}{"string", facet background color, defaults "white".} + +\item{pSize}{"num", point size.} + +\item{arrowType}{"string", arrow type (open/closed), default "closed".} + +\item{lineTextcol}{"string", facet background color, default "white".} + +\item{cornerTextSize}{"num", the corner label text size, default is 5.} + +\item{base_size}{"num", theme base size, default is 14.} + +\item{themebg}{Another theme style, default is "default", or "bwCorner".} + +\item{show.legend}{Whether show legend, default "TRUE".} + +\item{cornerVariable}{Which group corner axis to be added when "axes" set to "one", default is the first group.} + +\item{nLayout}{= NULL Similar to the ncol/nrow for the layout, default is the gene numbers.} + +\item{minExp}{Minimum expression value defined, default is NULL.} + +\item{maxExp}{Maxmum expression value defined, default is NULL.} +} +\value{ +Return a ggplot. +} +\description{ +Add corner axes on seurat UMAP/tSNE gene FeaturePlot function figures +} +\examples{ + +test <- system.file("extdata", "seuratTest.RDS", package = "scRNAtoolVis") + +tmp <- readRDS(test) + +# umap +featureCornerAxes( + object = tmp, reduction = "umap", + groupFacet = "orig.ident", + relLength = 0.5, relDist = 0.2, + features = c("Actb", "Ythdc1", "Ythdf2") +) + +# one axes +featureCornerAxes( + object = tmp, reduction = "umap", + groupFacet = "orig.ident", + features = c("Actb", "Ythdc1", "Ythdf2"), + relLength = 0.5, relDist = 0.2, + axes = "one", + lineTextcol = "grey50" +) + +# tsne +featureCornerAxes( + object = tmp, reduction = "tsne", + groupFacet = "orig.ident", + relLength = 0.5, relDist = 0.2, + features = c("Actb", "Ythdc1", "Ythdf2") +) + + +} +\author{ +Junjun Lao +}