During the lab session we practiced analyzing 10x Genomics data starting with output files from the 10x Genomics Cell Ranger pipeline. While this demonstrates how you might analyze new data that you generate, there are many public datasets that you may wish to explore starting with the analysis already conducted by the original authors. In this assignment, you will obtain data from the Tabula Muris Senis, a cell atlas of 23 tissues and organs from mice across their lifespan. The data are distributed by CZ CELLxGENE, which standardizes cell type labels using the Cell Ontology. After loading and exploring the quality of the Kidney dataset, you will identify marker genes and use gene set analysis to gain insights into the functions of different segments of the nephron.
Refer to the Bioconductor OSCA book for more information on
Use help() to display the built-in R Documentation for a given function (e.g. help(sort)) after loading the appropriate package

There are three exercises in this assignment:
Before you do anything else, create an R script for this assignment. Everything you’ll need to do for this assignment will be done in this script and submitted via GitHub. Use comments to separate your code blocks into Exercise 1, Step 1.1; Exercise 1, Step 1.2; etc., and include written answers to questions as comments. You must show your work to receive full credit for each question by providing the code you used.
The nephron is the functional unit of the kidney. Blood is filtered in the glomerulus and the filtrate is captured by Bowman’s capsule. As the filtrate flows along the tubule, each segment is lined by specialized epithelial cells that reabsorb or secrete different molecules
Kidney Nephron by Holly Fischer, CC BY 3.0
Besides nephron epithelial cells, the kidney also contains endothelial cells lining the blood vessels, stromal cells such as mesangial cells and fibroblasts, and resident and circulating immune cells.
Each of these appears as a cell_type in the Tabula Muris Senis data, e.g. kidney proximal convoluted tubule epithelial cell and kidney loop of Henle thick ascending limb epithelial cell.
Load the following packages using library()
Load Kidney data from CELLxGENE
kidney_10x.h5adkidney by loading kidney_10x.h5ad using readH5AD() from zellkonverter and setting reader="R"
BiocManager::install( "zellkonverter" )X assay contains values that were normalized and scaled by the authors. Replace it with the raw counts, which are stored inside the H5AD file at raw/X, and rename the assay to countsassay( kidney, "X", withDimnames=FALSE ) <- as( H5SparseMatrix( "kidney_10x.h5ad", "raw/X" ), "dgCMatrix" )
assayNames(kidney) <- "counts"
rownames(kidney) <- rowData(kidney)$feature_namekidney <- logNormCounts(kidney)Question 1: Inspect the kidney SingleCellExperiment object (0.5 pt)
Question 2: Inspect the available cell metadata (0.5 pt)
colData(kidney)?colnames() seem most interesting? Briefly explain why.X_umap using plotReducedDim() and colouring by cell_type and submit this plotSum the expression of each gene across all cells
genecounts by using rowSums() on the counts matrix returned by counts(kidney)Question 3: Explore the genecounts distribution (1 pt)
summary()? What might you conclude from these numbers?sort()? What do the gene names stand for?Question 4a: Explore the total expression in each cell across all genes (0.5 pt)
cellcounts using colSums()cellcounts using hist()Question 4b: Explore the number of genes detected in each cell (0.5 pt)
celldetected using colSums() but this time on counts(kidney)>0celldetected using hist()Solid tissues such as the kidney must be digested with enzymes at 37°C to release single cells. This dissociation can rapidly switch on immediate early genes (e.g. Fos, Jun, Egr1) and heat shock genes (e.g. Hspa1a), so the percent of reads from these stress genes is a useful quality metric. Sum the expression of a set of stress genes across each cell
stress of stress gene names using stress <- c( "Fos", "Fosb", "Jun", "Junb", "Egr1", "Atf3", "Ier2", "Hspa1a", "Hspa1b" )stress %in% rownames(kidney)df using perCellQCMetrics() specifying that subsets=list(Stress=stress)df to a data.frame using as.data.frame() and then running summary()colData(kidney) <- cbind( colData(kidney), df )Question 5: Visualize percent of reads from stress genes (1 pt)
plotColData() to plot the subsets_Stress_percent on the y-axis against the cell_type on the x-axis rotating the x-axis labels using theme( axis.text.x=element_text( angle=90, hjust=1, vjust=0.5 ) ) and submit this plotIdentify marker genes for every cell type compared with all other cells
marker.info that contains the pairwise comparisons between all cell types using scoreMarkers( kidney, colData(kidney)$cell_type )mean.AUC using the following codechosen <- marker.info[["kidney proximal convoluted tubule epithelial cell"]]
ordered <- chosen[order(chosen$mean.AUC, decreasing=TRUE),]
head(ordered[,1:4])
Question 6a: Evaluate top marker genes (1 pt)
plotExpression() and specifying the gene name as the feature and cell_type as the x-axis and submit this plotQuestion 6b: Gene set analysis (2 pt)
goi that contains the names of the top 200 genes of interest by rownames(ordered)[1:200]BiocManager::install( "org.Mm.eg.db" )ego <- enrichGO( goi, OrgDb=org.Mm.eg.db, keyType="SYMBOL", ont="BP", universe=rownames(kidney) )
head( ego )
dotplot( ego )
Repeat the analysis for the thick ascending limb of the loop of Henle
kidney loop of Henle thick ascending limb epithelial cellQuestion 7: Evaluate top marker genes (3 pt)
goi that contains the names of the top six genes of interest by rownames(ordered)[1:6]plotExpression() and specifying the goi vector as the features and submit this plotenrichGO() on the top 200 marker genes. What are the top GO terms, and why might this cell type need them?Submit an R script with your code and answers to questions for
Be sure to include the following plots