Skip to content

Instantly share code, notes, and snippets.

@vjcitn
Created November 1, 2025 13:09
Show Gist options
  • Select an option

  • Save vjcitn/86135435d4905a9bc03b6a5b6f2fb46f to your computer and use it in GitHub Desktop.

Select an option

Save vjcitn/86135435d4905a9bc03b6a5b6f2fb46f to your computer and use it in GitHub Desktop.
adjustable biplot for SummarizedExperiment
library(SummarizedExperiment)
library(irlba)
ibiplot = function(se, choices=1:2, nfeat=5, ircomp=6, ...) {
dat = t(assay(se))
pcs = prcomp_irlba(dat, ircomp)
rot = pcs$rotation
ss = rowSums(abs(rot[,choices])^2)
kp = order(ss, decreasing=TRUE)[seq_len(nfeat)]
labs = rep(" ", nrow(rot))
labs[kp] = rownames(se)[kp]
biplot(pcs, choices, ylabs=labs, ...)
}
library(airway)
data(airway)
rownames(airway) = make.names(rowData(airway)$gene_name, unique=TRUE)
ibiplot(airway, expand=.6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment