Normalization and exploring data for unwanted variation - Answer Key

Authors

Noor Sohail

Will Gammerdinger

Published

July 1, 2025

Exercise 1

  1. Plot the PCA similar to how we did with cell cycle regression. Hint: use the new mitoFrvariable to split cells and color them accordingly.
# Plot the PCA colored by mitoFr
DimPlot(seurat_phase,
        reduction = "pca",
        group.by= "mitoFr")

# Plot the PCA colored and split by mitoFr
DimPlot(seurat_phase,
        reduction = "pca",
        group.by= "mitoFr",
        split.by="mitoFr")

TODO: legend is cut off

sc.pl.pca(adata_phase, 
          color="mitoFr")

# Create plot with the correct dimensions
mito_groups = adata_phase.obs["mitoFr"].unique()
fig, axes = plt.subplots(1, len(mito_groups), 
                        figsize=(15, 5))

for idx, group in enumerate(mito_groups):
  # Plot the PCA colored and split by mitoFr
  sc.pl.pca(adata_phase, color="mitoFr", 
            groups=group, ax=axes[idx], 
            show=False, title=group)

plt.tight_layout()
plt.show()

  1. Evaluate the PCA plot generated above

    • Determine whether or not you observe an effect.

    Yes, there is an effect.

    • Describe what you see.

    Based on this plot, we can see that there is a different pattern of scatter for the plot containing cells with “High” mitochondrial expression. We observe that the lobe of cells one side of plot is where most of the cells with high mitochondrial expression are. For all other levels of mitochondrial expression we see a more even distribution of cells across the PCA plot.

    • Would you regress out mitochondrial fraction as a source of unwanted variation?

    Since we see this clear difference, we will regress out the ‘mitoRatio’ when we identify the most variant genes.

Exercise 2

  1. Are the same assays available for the “stim” samples within the split_seurat object? What is the code you used to check that?

Yes they are available. The code use is:

split_seurat$stim@assays
$RNA
Assay (v5) data with 14065 features for 14782 cells
Top 10 variable features:
 HBB, HBA2, CCL4L2, HBA1, IGKC, CCL7, PPBP, CCL4, CCL3, CCL8 
Layers:
 counts, data, scale.data 

$SCT
SCTAssay data with 13695 features for 14782 cells, and 1 SCTModel(s) 
Top 10 variable features:
 IGKC, CCL8, CCL2, FTL, GNLY, CXCL10, CCL7, CCL4, IGLC2, TIMP1 
  1. Any observations for the genes or features listed under “First 10 features:” and the “Top 10 variable features:” for “ctrl” versus “stim”?

For the first 10 features, it appears that the same genes are present in both “ctrl” and “stim”

For the top 10 variable features, these are different in the the 2 conditions with some overlap between them.


Back to Lesson >>

Back to Schedule