HW1
1. What data types are you visualizing?
I am visualizing quantitative gene expression count data (non-negative integer counts), specifically the total counts per gene aggregated across all spatial locations/cells.
2. What data encodings (geometric primitives and visual channels) are you using to visualize these data types?
I encode quantitative gene-count totals using x-position (log scale) and cumulative proportion using y-position; genes are drawn as points, and key quantiles are encoded as dashed vertical reference lines with text annotations.
3. What about the data are you trying to make salient through this data visualization?
The visualization makes salient the heavy-tailed distribution of total gene counts and the proportion of genes falling below key count thresholds, like median/90th/99th percentile markers.
4. What Gestalt principles or knowledge about perceptiveness of visual encodings are you using to accomplish this?
Similarity, Continuity
5. Code
library(readr) library(dplyr) library(ggplot2)
data <- read_csv(“Xenium-IRI-ShamR_matrix.csv”, show_col_types = FALSE)
counts <- data %>% select(-c(1:3)) counts_mat <- as.matrix(counts) storage.mode(counts_mat) <- “numeric”
col_sums <- tibble( gene = colnames(counts_mat), total_counts = colSums(counts_mat, na.rm = TRUE) ) %>% arrange(total_counts) %>% mutate( ecdf = row_number() / n() # F(x) )
qs <- quantile(col_sums$total_counts, probs = c(0.5, 0.9, 0.99), names = TRUE) q_df <- tibble( q = names(qs), x = as.numeric(qs), label = paste0(q, “: “, format(round(as.numeric(qs)), scientific = TRUE)) )
ggplot(col_sums, aes(x = total_counts + 1, y = ecdf)) + geom_point(alpha = 0.7, size = 2) + scale_x_log10() + geom_vline(data = q_df, aes(xintercept = x + 1), linetype = “dashed”) + geom_text( data = q_df, aes(x = x + 1, y = 0.05, label = label), angle = 90, vjust = -0.4, hjust = 0, size = 3, inherit.aes = FALSE ) + labs( title = “ECDF of Total Counts per Gene (each point = a gene)”, x = “Total counts per gene + 1 (log10 scale)”, y = “Fraction of genes ≤ x” ) + theme_minimal()