010‐ DE & Average expressions - rezakj/iCellR GitHub Wiki

Average expression per cluster

This refers to the calculation of the mean gene expression values for each cluster. By averaging the expression of genes within a cluster, you can summarize the overall expression profile of cell populations, making it easier to compare clusters and identify distinctive marker genes or biological patterns.

  • Option 1: all the cells in all the conditions/samples
# for all cunditions
my.obj <- clust.avg.exp(my.obj, conds.to.avg = NULL)
  • Option 2: choose condition/conditions
# for one cundition
#my.obj <- clust.avg.exp(my.obj, conds.to.avg = "WT")

# for two or more cunditions
#my.obj <- clust.avg.exp(my.obj, conds.to.avg = c("WT","KO"))

To examine the first few rows of the average expression data across clusters use the head() function.

head([email protected])
#      gene cluster_1   cluster_2   cluster_3   cluster_4   cluster_5
#1     A1BG         0 0.034248447 0.029590643 0.076486590 0.090270833
#2 A1BG.AS1         0 0.000000000 0.006274854 0.019724138 0.004700000
#3     A1CF         0 0.000000000 0.000000000 0.000000000 0.000000000
#4      A2M         0 0.006925466 0.003614035 0.000000000 0.000000000
#5  A2M.AS1         0 0.056155280 0.000000000 0.005344828 0.006795833
#6    A2ML1         0 0.000000000 0.000000000 0.000000000 0.000000000
#    cluster_6  cluster_7  cluster_8   cluster_9  cluster_10
#1 0.074360294 0.07623494 0.04522321 0.088735057 0.065292818
#2 0.000000000 0.00000000 0.01553869 0.013072698 0.013550645
#3 0.000000000 0.00000000 0.00000000 0.000000000 0.000000000
#4 0.000000000 0.00000000 0.00000000 0.001810985 0.003200737
#5 0.008191176 0.06227108 0.00000000 0.011621971 0.012837937
#6 0.000000000 0.00000000 0.00000000 0.000000000 0.000000000

Differential Expression (DE) Analysis in iCellR

The differential expression (DE) analysis function in iCellR provides users with flexibility to choose between various combinations of clusters and experimental conditions. This enables advanced comparisons and detailed insights into gene expression patterns across diverse biological contexts.

Possible Comparison Scenarios:

  • Cluster vs. Cluster Comparison: Compare the gene expression profile of one cluster/clusters against another cluster/clusters.

Example: Comparing cluster 1 and 2 vs. cluster 4.

  • Cluster Comparisons Within Specific Conditions: Compare clusters in one or more specific condition(s).

Example: Cluster 1 vs. Cluster 2 only in the "WT" (wild type) sample.

  • Condition vs. Condition Comparison: Perform differential expression analysis between experimental conditions regardless of cluster assignment.

Example: Comparing samples labeled "WT" vs. "KO" (knockout).

  • Condition Comparison Within Specific Clusters: Compare experimental conditions within specific cluster(s).

Example: Cluster 1 "WT" vs. Cluster 1 "KO".

diff.res <- run.diff.exp(my.obj, de.by = "clusters", cond.1 = c(1,4), cond.2 = c(2))
diff.res1 <- as.data.frame(diff.res)
diff.res1 <- subset(diff.res1, padj < 0.05)
head(diff.res1)
#             baseMean        1_4           2 foldChange log2FoldChange         pval
#AAK1       0.19554589 0.26338228 0.041792762 0.15867719      -2.655833 8.497012e-33
#ABHD14A    0.09645732 0.12708519 0.027038379 0.21275791      -2.232715 1.151865e-11
#ABHD14B    0.19132829 0.23177944 0.099644572 0.42991118      -1.217889 3.163623e-09
#ABLIM1     0.06901900 0.08749258 0.027148089 0.31029018      -1.688310 1.076382e-06
#AC013264.2 0.07383608 0.10584821 0.001279649 0.01208947      -6.370105 1.291674e-19
#AC092580.4 0.03730859 0.05112053 0.006003441 0.11743700      -3.090041 5.048838e-07
                   padj
#AAK1       1.294690e-28
#ABHD14A    1.708446e-07
#ABHD14B    4.636290e-05
#ABLIM1     1.540087e-02
#AC013264.2 1.950557e-15
#AC092580.4 7.254675e-03

# more examples 

# Comparing a condition/conditions with different condition/conditions (e.g. WT vs KO)
diff.res <- run.diff.exp(my.obj, de.by = "conditions", cond.1 = c("WT"), cond.2 = c("KO"))

# Comparing a cluster/clusters with different cluster/clusters (e.g. cluster 1 and 2 vs. 4)
diff.res <- run.diff.exp(my.obj, de.by = "clusters", cond.1 = c(1,4), cond.2 = c(2))

# Comparing a condition/conditions with different condition/conditions only in one/more cluster/clusters (e.g. cluster 1 WT vs cluster 1 KO)
diff.res <- run.diff.exp(my.obj, de.by = "clustBase.condComp", cond.1 = c("WT"), cond.2 = c("KO"), base.cond = 1)

# Comparing a cluster/clusters with different cluster/clusters only in one/more condition/conditions (e.g. cluster 1 vs cluster 2 but only the WT sample)
diff.res <- run.diff.exp(my.obj, de.by = "condBase.clustComp", cond.1 = c(1), cond.2 = c(2), base.cond = "WT")

Volcano and MA plots

# Volcano Plot 
volcano.ma.plot(diff.res,
	sig.value = "pval",
	sig.line = 0.05,
	plot.type = "volcano",
	interactive = F)

# MA Plot
volcano.ma.plot(diff.res,
	sig.value = "pval",
	sig.line = 0.05,
	plot.type = "ma",
	interactive = F)