annotate celesta_plot_expression.R @ 1:44d4c885d9b5 draft

planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 1f02a762ab43a29aa7f59760798ff084f86e37db
author goeckslab
date Thu, 12 Sep 2024 16:49:51 +0000
parents 8001319743c0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
1 # --------------------------------------------------------------------------------------------
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
2 # Plot marker expression probabilities for cell assignment parameter optimization with CELESTA
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
3 # --------------------------------------------------------------------------------------------
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
4
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
5 suppressWarnings(suppressMessages(library(janitor)))
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
6 suppressWarnings(suppressMessages(library(optparse)))
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
7 suppressWarnings(suppressMessages(library(dplyr)))
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
8 suppressWarnings(suppressMessages(library(anndataR)))
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
9 suppressWarnings(suppressMessages(library(Rmixmod)))
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
10 suppressWarnings(suppressMessages(library(spdep)))
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
11 suppressWarnings(suppressMessages(library(ggplot2)))
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
12 suppressWarnings(suppressMessages(library(reshape2)))
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
13 suppressWarnings(suppressMessages(library(zeallot)))
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
14 suppressWarnings(suppressMessages(library(CELESTA)))
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
15
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
16 ### Define command line arguments
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
17 option_list <- list(
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
18 make_option(c("-i", "--imagingdata"), action = "store", default = NA, type = "character",
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
19 help = "Path to imaging data"),
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
20 make_option(c("-p", "--prior"), action = "store", default = NA, type = "character",
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
21 help = "Path to prior marker info file"),
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
22 make_option(c("-x", "--xcol"), action = "store", default = NA, type = "character",
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
23 help = "Name of column in adata.obs containing X coordinate"),
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
24 make_option(c("-y", "--ycol"), action = "store", default = NA, type = "character",
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
25 help = "Name of column in adata.obs containing Y coordinate"),
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
26 make_option(c("--filter"), action = "store_true", type = "logical", default = FALSE,
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
27 help = "Boolean to filter cells or not (default: no filtering)"),
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
28 make_option(c("--highfilter"), action = "store", default = 0.9, type = "double",
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
29 help = "High marker threshold if filtering cells (default: 0.9)"),
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
30 make_option(c("--lowfilter"), action = "store", default = 0.4, type = "double",
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
31 help = "Low marker threshold if filtering cells (default: 0.4)"),
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
32 make_option(c("-s", "--size"), action = "store", default = 1, type = "double",
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
33 help = "Point size for plotting"),
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
34 make_option(c("--width"), action = "store", default = 5, type = "integer",
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
35 help = "Width of plot (inches)"),
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
36 make_option(c("--height"), action = "store", default = 4, type = "integer",
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
37 help = "Height of plot (inches)")
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
38 )
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
39
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
40 ### Functions
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
41 anndata_to_celesta <- function(input_adata, x_col, y_col) {
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
42
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
43 #' Function to convert anndata object to dataframe readable by CELESTA
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
44 #' Coordinates columns in adata.obs are renamed to "X" and "Y", and placed at beginning of dataframe
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
45 #' Marker intensities are concatted columnwise to the X and Y coords. cols: X,Y,Marker_1,...Marker N
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
46
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
47 # initialize output as dataframe from adata.obs
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
48 celesta_input_dataframe <- data.frame(input_adata$obs)
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
49
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
50 # subset to X and Y coordinates from obs only
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
51 celesta_input_dataframe <- celesta_input_dataframe %>%
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
52 dplyr::select({{x_col}}, {{y_col}})
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
53
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
54 # rename X,Y column names to what CELESTA wants
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
55 colnames(celesta_input_dataframe) <- c("X", "Y")
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
56
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
57 # merge X,Y coords with marker intensities from adata.X
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
58 x_df <- data.frame(input_adata$X)
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
59 colnames(x_df) <- input_adata$var_names
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
60 celesta_input_dataframe <- cbind(celesta_input_dataframe, x_df)
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
61
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
62 return(celesta_input_dataframe)
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
63 }
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
64
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
65 ### Main
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
66 # parse args
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
67 opt <- parse_args(OptionParser(option_list = option_list))
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
68
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
69 # read anndata, convert to celesta format
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
70 adata <- read_h5ad(opt$imagingdata)
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
71 celesta_input_df <- anndata_to_celesta(adata, x_col = opt$xcol, y_col = opt$ycol)
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
72
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
73 # read prior marker info
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
74 prior <- read.csv(opt$prior, check.names = FALSE)
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
75
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
76 # clean prior names, keeping a copy of originals for writing output
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
77 prior_original_names <- colnames(prior)
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
78 prior <- janitor::clean_names(prior, case = "all_caps")
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
79
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
80 # clean input dataframe names
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
81 celesta_input_df <- janitor::clean_names(celesta_input_df, case = "all_caps")
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
82
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
83 # instantiate celesta object
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
84 CelestaObj <- CreateCelestaObject(
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
85 project_title = "",
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
86 prior_marker_info = prior,
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
87 imaging_data_file = celesta_input_df
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
88 )
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
89
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
90 # if filtering is specified, filter out cells outside high and low thresholds
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
91 if (opt$filter) {
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
92 print("filtering cells based on expression")
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
93 CelestaObj <- FilterCells(CelestaObj,
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
94 high_marker_threshold = opt$highfilter,
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
95 low_marker_threshold = opt$lowfilter)
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
96 } else {
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
97 print("Proceeding to marker expression plotting without cell filtering")
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
98 }
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
99
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
100 # create output directory if it does not already exist
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
101 dir.create("marker_exp_plots")
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
102
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
103 # plot expression probability
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
104 PlotExpProb(coords = CelestaObj@coords,
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
105 marker_exp_prob = CelestaObj@marker_exp_prob,
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
106 prior_marker_info = CelestaObj@prior_info,
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
107 save_plot = TRUE,
8001319743c0 planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 0ec46718dfd00f37ccae4e2fa133fa8393fe6d92
goeckslab
parents:
diff changeset
108 output_dir = "./marker_exp_plots")