Skip to content

Commit

Permalink
fix columns
Browse files Browse the repository at this point in the history
  • Loading branch information
ivokwee committed Jul 30, 2024
1 parent a0238f4 commit e06bad7
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions components/board.dataview/R/dataview_table_rawdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,44 +139,49 @@ dataview_table_rawdata_server <- function(id,
}

dbg("[dataview_rawdata:table_data] create dataframe")
xgenes <- pgx$genes[rownames(x), "gene_name"]
gene.title <- playdata::GENE_TITLE[toupper(xgenes)]
pp <- rownames(x)
feature <- pgx$genes[pp, "feature"]
symbol <- pgx$genes[pp, "symbol"]
gene.title <- pgx$genes[pp, "gene_title"]
gene.title <- substring(gene.title, 1, 50)
if (is.null(rho)) {
x <- data.frame(
gene = xgenes, title = gene.title,
AVG = avg,
as.matrix(x), check.names = FALSE
)
} else {
x <- data.frame(
gene = xgenes, title = gene.title,
rho = rho, SD = sdx, AVG = avg,
as.matrix(x), check.names = FALSE
)

df <- data.frame(
gene = feature,
symbol = symbol,
title = gene.title,
rho = rho,
SD = sdx,
AVG = avg,
as.matrix(x),
check.names = FALSE
)

## if symbol and feature as same, drop symbol column
if(mean(head(df$gene,1000)==head(df$symbol,1000)) > 0.8) {
df$symbol <- NULL
}
x <- x[order(-x$rho, -x$SD), , drop = FALSE]

if (DATATYPEPGX == "proteomics") {
colnames(x)[1] <- "protein"
colnames(df)[1] <- "protein"
}
df <- df[order(-df$rho, -df$SD), , drop = FALSE]

list(
x = x,
df = df,
x95 = x95,
x99 = x99
)
})

rawdataTable.RENDER <- function() {
dt <- table_data()
req(dt, dt$x)
req(dt, dt$df)

numcols <- grep("gene|title", colnames(dt$x), value = TRUE, invert = TRUE)
numcols <- grep("gene|title", colnames(dt$df), value = TRUE, invert = TRUE)
tabH <- 700 ## height of table

DT::datatable(
dt$x,
dt$df,
rownames = FALSE,
fillContainer = TRUE, #
class = "compact hover",
Expand Down Expand Up @@ -204,7 +209,7 @@ dataview_table_rawdata_server <- function(id,

rawdataTable.RENDER_modal <- shiny::reactive({
dt <- rawdataTable.RENDER()
dt$x$options$scrollY <- SCROLLY_MODAL
dt$df$options$scrollY <- SCROLLY_MODAL
dt
})

Expand Down

0 comments on commit e06bad7

Please sign in to comment.