Skip to content

Commit

Permalink
Fix Feature table in cluster genes
Browse files Browse the repository at this point in the history
  • Loading branch information
zitoa committed Aug 13, 2024
1 parent a53c6c5 commit 3c06378
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions components/board.featuremap/R/featuremap_plot_table_gene_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,14 @@ featuremap_plot_gene_map_server <- function(id,
## select on table filter
F <- playbase::pgx.getMetaMatrix(pgx)$fc
F <- scale(F, center = FALSE)
fc <- sqrt(rowMeans(F**2))

## conform (NEED RETHINK when multiple symbols!)
## pos <- playbase::rename_by(pos, pgx$genes, "symbol")
## names(fc) <- pgx$genes$symbol[match(names(fc), rownames(pgx$genes), nomatch = 0)]
## fc <- fc[!duplicated(names(fc))]
## pos <- pos[!duplicated(rownames(pos)), , drop = FALSE]

fc <- sqrt(rowMeans(F**2, na.rm = TRUE))
names(fc) <- rownames(F)

gg <- intersect(rownames(pos), names(fc))
pos <- pos[gg, ]
pos <- pos[gg, , drop = FALSE]
fc <- fc[gg]
F <- F[gg, ]

F <- F[gg, , drop = FALSE]
hilight.probes <- playbase::map_probes(pgx$genes, hilight)
labels <- NULL
if (input$labeltype == "symbol") {
Expand Down Expand Up @@ -200,12 +195,13 @@ featuremap_plot_gene_map_server <- function(id,
F <- pd$F
annot <- pgx$genes

# Retreive gene table with rownames (symbols)
## Retrieve gene table with rownames (symbols)
annot_cols <- c("feature", "symbol", "human_ortholog", "gene_title")
annot_cols <- intersect(annot_cols, colnames(annot))
rowids <- match(rownames(F), rownames(annot))
annot <- annot[rowids, annot_cols, drop = FALSE]
annot <- apply(annot, MARGIN = 2, playbase::shortstring, n = 60)
annot <- as.data.frame(annot)

F <- cbind(rms.FC = fc, F)
F <- round(F, digits = 3)
Expand Down

0 comments on commit 3c06378

Please sign in to comment.