mts_plotClusterDistribution: Visualise samples and pairwise gene expression clusters

View source: R/mts_plotClusterDistribution.R

mts_plotClusterDistributionR Documentation

Visualise samples and pairwise gene expression clusters

Description

Produces a scatterplot with two selected genes on the x and y axis, the boundaries are determined by the cluster assignments (typically from Gaussian mixture modelling). Density plots of the clusters are also shown for each gene.

Axis scaling is chosen automatically: when a gene has a long high tail (as with many lncRNAs and other wide dynamic-range genes) that axis is square-root, or pseudo-log, transformed for improved visualisation of low-expression clusters (not compressed). This axis scaling is applied independently to each axis, for whichever gene needs it, whether it is supplied as gene1 or gene2.

Usage

mts_plotClusterDistribution(mixModelClusters, 
                            mixModelClusters2 = NULL, 
                            TScluster1 = NULL,
                            TScluster2 = NULL,
                            gene1, gene2, 
                            suppressBlankCanvas = NULL, 
                            gene1_datatype = "", 
                            gene2_datatype = "")

Arguments

mixModelClusters

A list object containing cluster assignments generated by mts_mixModelCluster, mts_mixModelCluster_XPR, mts_crisprPartition, or mts_formatMatrix.

mixModelClusters2

Optional. A second list object containing cluster assignments generated by mts_mixModelCluster, mts_mixModelCluster_XPR, mts_crisprPartition or mts_formatMatrix. If supplied, gene pairs are generated between genes in mixModelClusters1 and genes in mixModelClusters2, where the data for gene2 is taken from this object. This functionality is useful for visualisation of more than one data type, for example integrating CRISPR gene effect scores with gene expression data.

TScluster1

Optional. List object containing tissue-specific cluster assignments (and values) for the results of mts_mixModelCluster, mts_mixModelCluster_XPR, mts_crisprPartition or mts_formatMatrix. Tissue-specific samples are coloured in red in the scatter plot. If the argument is not called or left as NULL then all samples from mixModelClusters will be coloured (according to the pairwise cluster combinations).

TScluster2

Optional. List object containing tissue-specific cluster assignments (and values) for the results of mts_mixModelCluster, mts_mixModelCluster_XPR, mts_crisprPartition or mts_formatMatrix. Tissue-specific samples are coloured in red in the scatter plot. If the argument is not called or left as NULL then all samples from mixModelClusters will be coloured (according to the pairwise cluster combinations).

gene1

User specified gene 1. Must match a gene in the list object containing cluster assignments (i.e. mixModelClusters).

gene2

User specified gene 2. Must match a gene in the list object containing cluster assignments (i.e. mixModelClusters or mixModelClusters2).

gene1_datatype

Optional. Text provided to this argument is included next to gene1 in the plot, intended to allow display of data-related information for that gene; for example 'log2 gene expression (TPM)'.

gene2_datatype

Optional. Text provided to this argument is included next to gene2 in the plot, intended to allow display of data-related information for that gene; for example 'CRISPR gene effect score'

suppressBlankCanvas

Optional. Prevents calling plot.new, which makes a blank canvas. Can be set to TRUE if writing a plot to file in order to avoid writing a blank page in addition to the plot. Default value is NULL.

Value

A patchwork object combining a scatter plot with the two panels showing density, which can be printed or saved with ggsave. If suppressBlankCanvas is set, the plot is printed and returned invisibly.

See Also

mts_mixModelCluster, mts_mixModelCluster_XPR, mts_crisprPartition, mts_genepairsChunkGeneration, mts_formatMatrix, mts_plotClusterDistribution,

Examples

data("mixModelClusters_depMapXPR")
data("depMapCRISPRscores_subset")
data("depMapTissue_subset")

# Plot with gene expression data for both genes
mts_plotClusterDistribution(
  mixModelClusters = mixModelClusters_depMapXPR, 
  gene1 = "NMT2", 
  gene2="STX2"
)

##
## Plot gene expression with CRISPR gene effect scores
##
# partition CRISPR scores at -0.5
CRISPR_clusters = mts_crisprPartition(dataMatrix = depMapCRISPRscores_subset[4,])
mts_plotClusterDistribution(mixModelClusters = mixModelClusters_depMapXPR,
                            mixModelClusters2 = CRISPR_clusters,
                            gene1 = "NMT2", gene2 = "NMT1",
                            gene1_datatype="log2 gene expression",
                            gene2_datatype = "CRISPR gene effect score")

##
## Tissue-specific plot
##

mixturemodelClusters <- mts_mixModelCluster_XPR(dataMatrix = depMapXPR_subset[14,])
# partition CRISPR scores at -0.5
CRISPR_clusters = mts_crisprPartition(dataMatrix = depMapCRISPRscores_subset[9,])

# 1. subset cell lines of interest using mapping file 
Lung_Cancer_cellLines <- depMapTissue_subset$cell_line[
  depMapTissue_subset$tissue == "Lung Cancer"]

# 2. subset XPR mixture model result list 
LungCancer_XPRmixturemodelClusters <- lapply(mixturemodelClusters, function(GMM) {
    GMM[GMM$Sample %in% Lung_Cancer_cellLines, ]})

# 3. subset CRISPR clusters
LungCancer_CRISPR_Clusters <- lapply(CRISPR_clusters, function(GMM) {
  GMM[GMM$Sample %in% Lung_Cancer_cellLines, ]})

mts_plotClusterDistribution(gene1 = "ACSL1", gene2 = "PSMB5",
                            mixModelClusters = mixturemodelClusters,
                            mixModelClusters2 = CRISPR_clusters,
                            TScluster1 = LungCancer_XPRmixturemodelClusters, 
                            TScluster2 = LungCancer_CRISPR_Clusters)


MultiSEp documentation built on Aug. 27, 2026, 5:07 p.m.