Mercurial > repos > iuc > raceid_inspectclusters
changeset 10:c7ddb719554d draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit 0ffa71ef9f8d020fe7ba94502db8cec26fd8741f
author | iuc |
---|---|
date | Tue, 05 Nov 2024 16:33:10 +0000 |
parents | f3eb2291da05 |
children | |
files | macros.xml raceid_inspectclusters.xml scripts/cluster.R scripts/clusterinspect.R scripts/pseudotemporal.R scripts/trajectoryinspect.R |
diffstat | 6 files changed, 117 insertions(+), 70 deletions(-) [+] |
line wrap: on
line diff
--- a/macros.xml Wed Aug 24 18:11:37 2022 +0000 +++ b/macros.xml Tue Nov 05 16:33:10 2024 +0000 @@ -52,6 +52,11 @@ <!-- <requirement type="package" version="1.6.2">bioconductor-scran</requirement> --> </requirements> </macro> + <xml name="bio_tools"> + <xrefs> + <xref type="bio.tools">RaceID</xref> + </xrefs> + </xml> <macro name="yesno_checkedno" > <option value="yes" >Yes</option> <option value="no" selected="true" >No</option>
--- a/raceid_inspectclusters.xml Wed Aug 24 18:11:37 2022 +0000 +++ b/raceid_inspectclusters.xml Tue Nov 05 16:33:10 2024 +0000 @@ -34,6 +34,7 @@ </section> </macro> </macros> + <expand macro="bio_tools"/> <expand macro="requirements" /> <expand macro="version_command_config" prog="clusterinspect.R" cheetah="INSPECTCLUSTERS_CHEETAH" out="&> '$outlog'" /> <inputs>
--- a/scripts/cluster.R Wed Aug 24 18:11:37 2022 +0000 +++ b/scripts/cluster.R Tue Nov 05 16:33:10 2024 +0000 @@ -4,8 +4,8 @@ args <- commandArgs(trailingOnly = TRUE) if (length(args) != 1) { - message(paste("VERSION:", VERSION)) - stop("Please provide the config file") + message(paste("VERSION:", VERSION)) + stop("Please provide the config file") } suppressWarnings(suppressPackageStartupMessages(require(RaceID))) @@ -17,8 +17,9 @@ if (!is.null(filt.lbatch.regexes)) { lar <- filt.lbatch.regexes nn <- colnames(sc@expdata) - filt$LBatch <- lapply(1:length(lar), function(m) { # nolint - return(nn[grep(lar[[m]], nn)])}) + filt$LBatch <- lapply(1:length(lar), function(m) { # nolint + return(nn[grep(lar[[m]], nn)]) + }) } sc <- do.call(filterdata, c(sc, filt)) @@ -44,9 +45,12 @@ unq <- unique(filt_feat) if (length(unq) == 1) { abline(v = unq, col = "red", lw = 2) - text(tmp$mids, table(filt_feat)[[1]] - 100, pos = 1, - paste(10^unq, "\nFeatures\nin remaining\nCells", - sep = ""), cex = 0.8) + text(tmp$mids, table(filt_feat)[[1]] - 100, + pos = 1, + paste(10^unq, "\nFeatures\nin remaining\nCells", + sep = "" + ), cex = 0.8 + ) } if (filt.use.ccorrect) { @@ -80,7 +84,7 @@ ## Heatmaps test1 <- list() test1$side <- 3 - test1$line <- 0 #1 #3 + test1$line <- 0 # 1 #3 x <- clustheatmap(sc, final = FALSE) print(do.call(mtext, c(paste("(Initial)"), test1))) @@ -122,8 +126,10 @@ test$line <- -1 print(do.call(mtext, c(paste(buffer, "Sig. Genes"), test))) test$line <- 0 - print(do.call(mtext, c(paste(buffer, "(fc > ", - genelist.foldchange, ")"), test))) + print(do.call(mtext, c(paste( + buffer, "(fc > ", + genelist.foldchange, ")" + ), test))) }) write.table(df, file = out.genelist, sep = "\t", quote = FALSE) } @@ -131,14 +137,18 @@ writecellassignments <- function(sc) { dat <- sc@cluster$kpart - tab <- data.frame(row.names = NULL, - cells = names(dat), - cluster.initial = dat, - cluster.final = sc@cpart, - is.outlier = names(dat) %in% sc@out$out) + tab <- data.frame( + row.names = NULL, + cells = names(dat), + cluster.initial = dat, + cluster.final = sc@cpart, + is.outlier = names(dat) %in% sc@out$out + ) - write.table(tab, file = out.assignments, sep = "\t", - quote = FALSE, row.names = FALSE) + write.table(tab, + file = out.assignments, sep = "\t", + quote = FALSE, row.names = FALSE + ) } @@ -146,19 +156,29 @@ if (use.filtnormconf) { sc <- do.filter(sc) - message(paste(" - Source:: genes:", nrow(sc@expdata), - ", cells:", ncol(sc@expdata))) - message(paste(" - Filter:: genes:", nrow(as.matrix(getfdata(sc))), - ", cells:", ncol(as.matrix(getfdata(sc))))) - message(paste(" :: ", - sprintf("%.1f", 100 * nrow(as.matrix( - getfdata(sc))) / nrow(sc@expdata)), - "% of genes remain,", - sprintf("%.1f", 100 * ncol(as.matrix( - getfdata(sc))) / ncol(sc@expdata)), - "% of cells remain")) - write.table(as.matrix(sc@ndata), file = out.table, col.names = NA, - row.names = TRUE, sep = "\t", quote = FALSE) + message(paste( + " - Source:: genes:", nrow(sc@expdata), + ", cells:", ncol(sc@expdata) + )) + message(paste( + " - Filter:: genes:", nrow(as.matrix(getfdata(sc))), + ", cells:", ncol(as.matrix(getfdata(sc))) + )) + message(paste( + " :: ", + sprintf("%.1f", 100 * nrow(as.matrix( + getfdata(sc) + )) / nrow(sc@expdata)), + "% of genes remain,", + sprintf("%.1f", 100 * ncol(as.matrix( + getfdata(sc) + )) / ncol(sc@expdata)), + "% of cells remain" + )) + write.table(as.matrix(sc@ndata), + file = out.table, col.names = NA, + row.names = TRUE, sep = "\t", quote = FALSE + ) } if (use.cluster) {
--- a/scripts/clusterinspect.R Wed Aug 24 18:11:37 2022 +0000 +++ b/scripts/clusterinspect.R Tue Nov 05 16:33:10 2024 +0000 @@ -1,11 +1,11 @@ #!/usr/bin/env R -VERSION <- "0.5" # nolint +VERSION <- "0.5" # nolint args <- commandArgs(trailingOnly = TRUE) if (length(args) != 1) { - message(paste("VERSION:", VERSION)) - stop("Please provide the config file") + message(paste("VERSION:", VERSION)) + stop("Please provide the config file") } suppressWarnings(suppressPackageStartupMessages(require(RaceID))) @@ -49,15 +49,18 @@ } -do.inspect.symbolmap <- function(sc) { # nolint +do.inspect.symbolmap <- function(sc) { # nolint if (!is.null(plotsym.use.typeremoveregex)) { - plotsym$types <- sub(plotsym.use.typeremoveregex, "", - colnames(sc@ndata)) + plotsym$types <- sub( + plotsym.use.typeremoveregex, "", + colnames(sc@ndata) + ) if (!is.null(plotsym.use.typeremoveregex.subselect)) { plotsym$subset <- plotsym$types[grep( - plotsym.use.typeremoveregex.subselect, - plotsym$types)] + plotsym.use.typeremoveregex.subselect, + plotsym$types + )] } } plotsym$fr <- FALSE @@ -68,16 +71,16 @@ print(do.call(mtext, c("Symbols FR", test))) } -do.inspect.diffgene <- function(sc) { # nolint +do.inspect.diffgene <- function(sc) { # nolint - getSubNames <- function(lob, sc) { # nolint + getSubNames <- function(lob, sc) { # nolint use_names <- NULL if (!is.null(lob$manual)) { use_names <- lob$manual - }else if (!is.null(lob$regex)) { + } else if (!is.null(lob$regex)) { nm <- colnames(sc@ndata) use_names <- nm[grep(lob$regex, nm)] - }else if (!is.null(lob$cln)) { + } else if (!is.null(lob$cln)) { use_names <- names(sc@cpart)[sc@cpart %in% lob$cln] } if (is.null(use_names)) { @@ -98,7 +101,7 @@ } -do.inspect.genesofinterest <- function(sc) { # nolint +do.inspect.genesofinterest <- function(sc) { # nolint if (is.null(plotexp$n)) { ## No title, and one gene? Use gene name if (length(plotexp$g) == 1) { plotexp$n <- plotexp$g
--- a/scripts/pseudotemporal.R Wed Aug 24 18:11:37 2022 +0000 +++ b/scripts/pseudotemporal.R Tue Nov 05 16:33:10 2024 +0000 @@ -4,8 +4,8 @@ args <- commandArgs(trailingOnly = T) # nolint if (length(args) != 1) { - message(paste("VERSION:", VERSION)) - stop("Please provide the config file") + message(paste("VERSION:", VERSION)) + stop("Please provide the config file") } suppressWarnings(suppressPackageStartupMessages(require(RaceID))) @@ -29,20 +29,31 @@ ltr <- do.call(comppvalue, c(ltr, pstc.comppval)) x <- do.call(compscore, c(ltr, pstc.compscore)) print(do.call(mtext, c("Compute Score", test))) - print(do.call(mtext, c(paste0("No. of inter-cluster links / ", - "Delta median entropy of each cluster / ", - "StemID2 score (combination of both)"), - second))) + print(do.call(mtext, c( + paste0( + "No. of inter-cluster links / ", + "Delta median entropy of each cluster / ", + "StemID2 score (combination of both)" + ), + second + ))) plotdistanceratio(ltr) print(do.call(mtext, c("Cell-to-Cell Distance Ratio", test))) - print(do.call(mtext, c("Original vs High-dimensional Embedded Space", - second))) + print(do.call(mtext, c( + "Original vs High-dimensional Embedded Space", + second + ))) do.call(plotgraph, c(ltr, pstc.plotgraph)) print(do.call(mtext, c(paste0(c("Lineage Trajectories", rep(" ", 54)), - collapse = ""), test))) - print(do.call(mtext, c(paste0(c(paste0("Colour = Level of Significance, ", - "Width = Link Score"), - rep(" ", 106)), collapse = ""), second))) + collapse = "" + ), test))) + print(do.call(mtext, c(paste0(c( + paste0( + "Colour = Level of Significance, ", + "Width = Link Score" + ), + rep(" ", 106) + ), collapse = ""), second))) plotspantree(ltr) print(do.call(mtext, c("Minimum Spanning Tree", test))) plotspantree(ltr, projections = TRUE)
--- a/scripts/trajectoryinspect.R Wed Aug 24 18:11:37 2022 +0000 +++ b/scripts/trajectoryinspect.R Tue Nov 05 16:33:10 2024 +0000 @@ -4,8 +4,8 @@ args <- commandArgs(trailingOnly = TRUE) if (length(args) != 1) { - message(paste("VERSION:", VERSION)) - stop("Please provide the config file") + message(paste("VERSION:", VERSION)) + stop("Please provide the config file") } suppressWarnings(suppressPackageStartupMessages(require(RaceID))) @@ -34,7 +34,8 @@ ) write.table( head(bra$diffgenes$z, trjsid.numdiffgenes), - file = out.diffgenes) + file = out.diffgenes + ) par(mfrow = c(3, 2), cex = 0.5) print(do.call(plotmap, c(bra$scl, final = FALSE, fr = FALSE))) @@ -63,7 +64,7 @@ trjfid_procsom$s1d <- s1d ps <- do.call(procsom, c(trjfid_procsom)) - y <- ltr@sc@cpart[n$f] + y <- ltr@sc@cpart[n$f] fcol <- ltr@sc@fcol trjfid_plotheat$xpart <- y @@ -72,26 +73,32 @@ test$side <- 3 test$line <- 3 - ##Plot average z-score for all modules derived from the SOM: + ## Plot average z-score for all modules derived from the SOM: trjfid_plotheat$x <- ps$nodes.z trjfid_plotheat$ypart <- unique(ps$nodes) print(do.call(plotheatmap, c(trjfid_plotheat))) - print(do.call(mtext, c("Average z-score for all modules derived from SOM", - test))) - ##Plot z-score profile of each gene ordered by SOM modules: + print(do.call(mtext, c( + "Average z-score for all modules derived from SOM", + test + ))) + ## Plot z-score profile of each gene ordered by SOM modules: trjfid_plotheat$x <- ps$all.z trjfid_plotheat$ypart <- ps$nodes print(do.call(plotheatmap, c(trjfid_plotheat))) - print(do.call(mtext, c(paste0("z-score profile of each gene", - "ordered by SOM modules"), test))) - ##Plot normalized expression profile of each gene ordered by SOM modules: + print(do.call(mtext, c(paste0( + "z-score profile of each gene", + "ordered by SOM modules" + ), test))) + ## Plot normalized expression profile of each gene ordered by SOM modules: trjfid_plotheat$x <- ps$all.e trjfid_plotheat$ypart <- ps$nodes print(do.call(plotheatmap, c(trjfid_plotheat))) - print(do.call(mtext, c(paste0("Normalized expression profile of each", - "gene ordered by SOM modules"), test))) - ##Plot binarized expression profile of each gene - ##(z-score < -1, -1 < z-score < 1, z-score > 1) + print(do.call(mtext, c(paste0( + "Normalized expression profile of each", + "gene ordered by SOM modules" + ), test))) + ## Plot binarized expression profile of each gene + ## (z-score < -1, -1 < z-score < 1, z-score > 1) trjfid_plotheat$x <- ps$all.b trjfid_plotheat$ypart <- ps$nodes print(do.call(plotheatmap, c(trjfid_plotheat)))