Skip to content

Commit

Permalink
Adding more space around the plots
Browse files Browse the repository at this point in the history
  • Loading branch information
AlicenJoyHenning committed Sep 12, 2024
1 parent edb1fb4 commit 875e900
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions R/create_imc_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' @export
#'
#' @keywords internal
#'
#'
#' @examples
#' \dontrun{
#' # Example usage:
Expand Down Expand Up @@ -48,8 +48,8 @@ create_imc_plot <- function(imc_df, project_name, IMC_percent) {
) +
theme_classic() +
theme(
plot.margin = unit(c(0.2, 0.2, 0.2, 0.4), 'cm'),
plot.title = element_text(hjust = 0.5, face = "bold", size = 12),
plot.margin = unit(c(1, 1, 1, 1), 'cm'),
axis.title.x = element_text(hjust = 0.5, vjust = -1, face = "bold", size = 12),
axis.title.y = element_text(hjust = 0.5, vjust = 3, face = "bold", size = 12),
axis.text.x = element_text(angle = 0, hjust = 0.5, vjust = -1.2, size = 12),
Expand Down
6 changes: 3 additions & 3 deletions R/create_rbc_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' @export
#'
#' @keywords internal
#'
#'
#' @examples
#' \dontrun{
#' # Assuming `rbc_data` is a data frame containing the RBC data.
Expand All @@ -30,7 +30,7 @@
#' project_name <- "RBC Contamination Analysis"
#' RBC_percent <- 15.0
#' initial_cells <- 1000
#'
#'
#' plot <- create_rbc_plot(rbc_data, project_name, RBC_percent, initial_cells)
#' print(plot)
#' }
Expand Down Expand Up @@ -61,8 +61,8 @@ create_rbc_plot <- function(rbc_df, project_name, RBC_percent, initial_cells) {
legend.position = "below",
legend.box.background = element_rect(colour = "black"),
strip.background = element_blank(),
plot.margin = unit(c(0.2, 0.2, 0.2, 0.4), 'cm'),
plot.title = element_text(hjust = 0.5, face = "bold", size = 12),
plot.margin = unit(c(1, 1, 1, 1), 'cm'),
panel.background = element_blank(),
panel.grid = element_blank(),
panel.border = element_rect(colour = "black", fill = NA, linewidth = 1)
Expand Down
18 changes: 9 additions & 9 deletions R/limiric_core.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ limiric_core <- function(
){
# Receive & prepare input ------------------------------------

message("\nBeginning limiric analysis for", project_name, "...\n")
message("\nBeginning limiric analysis for ", project_name, "...\n")

# Ensure calculations are reproducible
set.seed(7777)
Expand Down Expand Up @@ -356,7 +356,7 @@ limiric_core <- function(
limiric <- limiric_output$limiric


message("\u2714 limiric damaged cell predictions\n")
message("\u2714 limiric damaged cell predictions\n")



Expand Down Expand Up @@ -441,7 +441,7 @@ limiric_core <- function(
annotated_cells <- merge(storage_cells, clean_cells, by = "barcode", all.x = TRUE)
annotated_cells$QC_annotation[is.na(annotated_cells$QC_annotation)] <- "removed"

write.csv(annotated_cells, file = file.path(output_path, "DropletQC", paste0(project_name, "_barcodes.csv")), row.names = FALSE)
write.csv(annotated_cells, file = file.path(output_path, "DropletQC", paste0(project_name, "_barcodes.csv")), row.names = FALSE, quote = FALSE)

# Rename column
Seurat$limiric.droplet_qc <- Seurat$QC
Expand All @@ -459,7 +459,7 @@ limiric_core <- function(

# Save a list of barcodes with limiric annotations (cell, damaged)
clean_cells <- data.frame(barcode = rownames(Seurat@meta.data), limiric = Seurat@meta.data$limiric)
write.csv(clean_cells, file = file.path(output_path, "Filtered", paste0(project_name, "_barcodes.csv")), row.names = FALSE)
write.csv(clean_cells, file = file.path(output_path, "Filtered", paste0(project_name, "_barcodes.csv")), row.names = FALSE, quote = FALSE)

Seurat <- subset(Seurat, QC != "agreed")

Expand All @@ -482,13 +482,13 @@ limiric_core <- function(
# Save a list of barcodes with limiric annotations (cell, damaged)
storage_cells <- data.frame(barcode = rownames(storage@meta.data))
clean_cells <- data.frame(barcode = rownames(Seurat@meta.data), limiric = Seurat@meta.data$limiric)
write.csv(clean_cells, file = file.path(output_path, "/Filtered/", paste0(project_name, "_barcodes.csv")), row.names = FALSE)
write.csv(clean_cells, file = file.path(output_path, "/Filtered/", paste0(project_name, "_barcodes.csv")), row.names = FALSE, quote = FALSE)

# Account for cells that may have been filtered
annotated_cells <- merge(storage_cells, clean_cells, by = "barcode", all.x = TRUE)
annotated_cells$limiric[is.na(annotated_cells$limiric)] <- "removed"

write.csv(annotated_cells, file = file.path(output_path, "Filtered", paste0(project_name, "_barcodes.csv")), row.names = FALSE)
write.csv(annotated_cells, file = file.path(output_path, "Filtered", paste0(project_name, "_barcodes.csv")), row.names = FALSE, quote = FALSE)


# Filter damaged cells only according to limiric estimations
Expand All @@ -515,18 +515,18 @@ limiric_core <- function(
# Save a list of barcodes with limiric annotations (cell, damaged)
storage_cells <- data.frame(barcode = rownames(storage@meta.data))
clean_cells <- data.frame(barcode = rownames(Seurat@meta.data), limiric = Seurat@meta.data$limiric)
write.csv(clean_cells, file = file.path(output_path, "/Filtered/", paste0(project_name, "_barcodes.csv")), row.names = FALSE)
write.csv(clean_cells, file = file.path(output_path, "/Filtered/", paste0(project_name, "_barcodes.csv")), row.names = FALSE, quote = FALSE)

# Account for cells that may have been filtered
annotated_cells <- merge(storage_cells, clean_cells, by = "barcode", all.x = TRUE)
annotated_cells$limiric[is.na(annotated_cells$limiric)] <- "removed"

write.csv(annotated_cells, file = file.path(output_path, "Filtered", paste0(project_name, "_barcodes.csv")), row.names = FALSE)
write.csv(annotated_cells, file = file.path(output_path, "Filtered", paste0(project_name, "_barcodes.csv")), row.names = FALSE, quote = FALSE)
saveRDS(Seurat, file.path(output_path, "Filtered", paste0(project_name, "_unfiltered.rds")))

}

message("\u2714 limiric analysis complete.\n\n")
message("\u2714 limiric analysis complete\n\n")

return(Seurat)

Expand Down

0 comments on commit 875e900

Please sign in to comment.