From 3a7ae96099b5c7b1257ed80226a9ce90915d67c5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 3 Nov 2023 14:30:23 +0000 Subject: [PATCH 1/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- R/mouse_deconvolution_methods.R | 47 ++++++++++++----------- tests/testthat/test_deconvolution_mouse.R | 4 +- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/R/mouse_deconvolution_methods.R b/R/mouse_deconvolution_methods.R index f735d05..4b166f0 100644 --- a/R/mouse_deconvolution_methods.R +++ b/R/mouse_deconvolution_methods.R @@ -260,7 +260,7 @@ deconvolute_mouse <- function(gene_expression_matrix, #' #' @export convert_human_mouse_genes <- function(gene_expression_matrix, mirror = "www", - other_annot = TRUE, convert_to = c('human', 'mouse')) { + other_annot = TRUE, convert_to = c("human", "mouse")) { gene.names <- rownames(gene_expression_matrix) gene_expression_matrix$gene_name <- gene.names @@ -270,25 +270,25 @@ convert_human_mouse_genes <- function(gene_expression_matrix, mirror = "www", genes.retrieved <- NULL tryCatch( expr = { - - if(convert_to == 'human'){ - mart.use = mouse - mart.link = human - attr = 'mgi_symbol' - attr.link = 'hgnc_symbol' + if (convert_to == "human") { + mart.use <- mouse + mart.link <- human + attr <- "mgi_symbol" + attr.link <- "hgnc_symbol" } else { - mart.use = human - mart.link = mouse - attr = 'hgnc_symbol' - attr.link = 'mgi_symbol' + mart.use <- human + mart.link <- mouse + attr <- "hgnc_symbol" + attr.link <- "mgi_symbol" } genes.retrieved <<- getLDS( attributes = c(attr), filters = attr, values = gene.names, - mart = mart.use, attributesL = c(attr.link), martL = mart.link, uniqueRows = T) + mart = mart.use, attributesL = c(attr.link), martL = mart.link, uniqueRows = T + ) - if(convert_to == 'human'){ + if (convert_to == "human") { newGenes.counts <<- gene_expression_matrix %>% left_join(., genes.retrieved, by = c("gene_name" = "MGI.symbol")) %>% select(., -c("gene_name")) %>% @@ -301,21 +301,19 @@ convert_human_mouse_genes <- function(gene_expression_matrix, mirror = "www", } }, error = function(e) { - if (other_annot) { print("Cannot connect to ENSEMBL. Using alternative method. This will take some time.") # Code adapted from: https://support.bioconductor.org/p/129636/#9144606 mouse_human_genes <- read.csv("http://www.informatics.jax.org/downloads/reports/HOM_MouseHumanSequence.rpt", sep = "\t") - find_corr_gene <- function(gene, mouse_human_genes_df, convert_to = c('human', 'mouse')) { - - if(convert_to == 'human'){ - orgn.name <- 'mouse, laboratory' - new.orgn <- 'human' + find_corr_gene <- function(gene, mouse_human_genes_df, convert_to = c("human", "mouse")) { + if (convert_to == "human") { + orgn.name <- "mouse, laboratory" + new.orgn <- "human" } else { - orgn.name <- 'human' - new.orgn <- 'mouse, laboratory' + orgn.name <- "human" + new.orgn <- "mouse, laboratory" } class_key <- (mouse_human_genes_df %>% @@ -330,8 +328,11 @@ convert_human_mouse_genes <- function(gene_expression_matrix, mirror = "www", } if (!is.null(output)) { - return(data.frame("new_gene" = output, - "old_gene" = gene))} + return(data.frame( + "new_gene" = output, + "old_gene" = gene + )) + } } } diff --git a/tests/testthat/test_deconvolution_mouse.R b/tests/testthat/test_deconvolution_mouse.R index 36f487d..c3bcec2 100644 --- a/tests/testthat/test_deconvolution_mouse.R +++ b/tests/testthat/test_deconvolution_mouse.R @@ -40,12 +40,12 @@ test_that("generic deconvolution works for all methods", { }) test_that("mouse gene names can be converted into their human orthologus, and vice versa", { - test_mat_newGenes = convert_human_mouse_genes(test_mat[1:1000, ], convert_to = 'human') + test_mat_newGenes <- convert_human_mouse_genes(test_mat[1:1000, ], convert_to = "human") assert("matrix dimensions consistent", ncol(test_mat_newGenes) == ncol(test_mat)) test_mat_human <- read_tsv("bulk_mat.tsv") %>% as.data.frame() %>% tibble::column_to_rownames("gene_symbol") - test_mat_newGenes = convert_human_mouse_genes(test_mat_human[1:1000, ], convert_to = 'mouse') + test_mat_newGenes <- convert_human_mouse_genes(test_mat_human[1:1000, ], convert_to = "mouse") assert("matrix dimensions consistent", ncol(test_mat_newGenes) == ncol(test_mat)) }) From e9af77051c1f278ecb8f8508951aa3ca503b0a3d Mon Sep 17 00:00:00 2001 From: LorenzoMerotto Date: Fri, 3 Nov 2023 14:45:48 +0000 Subject: [PATCH 2/2] Roxygenize --- man/convert_human_mouse_genes.Rd | 7 ------- 1 file changed, 7 deletions(-) diff --git a/man/convert_human_mouse_genes.Rd b/man/convert_human_mouse_genes.Rd index 964d5e8..2ee672c 100644 --- a/man/convert_human_mouse_genes.Rd +++ b/man/convert_human_mouse_genes.Rd @@ -4,18 +4,11 @@ \alias{convert_human_mouse_genes} \title{This function converts the mouse gene symbols into corresponding human ones, and vice versa.} \usage{ -<<<<<<< HEAD:man/convert_human_mouse_genes.Rd convert_human_mouse_genes( gene_expression_matrix, mirror = "www", other_annot = TRUE, convert_to = c("human", "mouse") -======= -mouse_genes_to_human( - gene_expression_matrix, - mirror = "www", - other_annot = TRUE ->>>>>>> a7e4ee9993aa94f268e862263eaf226a251514f9:man/mouse_genes_to_human.Rd ) } \arguments{