@@ -268,9 +268,11 @@ mouse_genes_to_human <- function(gene_expression_matrix, mirror = "www", other_a
268
268
genes.retrieved <- NULL
269
269
tryCatch(
270
270
expr = {
271
- genes.retrieved <<- getLDS(attributes = c(" mgi_symbol" ),
272
- filters = " mgi_symbol" , values = gene.names.mouse ,
273
- mart = mouse , attributesL = c(" hgnc_symbol" ), martL = human , uniqueRows = T )
271
+ genes.retrieved <<- getLDS(
272
+ attributes = c(" mgi_symbol" ),
273
+ filters = " mgi_symbol" , values = gene.names.mouse ,
274
+ mart = mouse , attributesL = c(" hgnc_symbol" ), martL = human , uniqueRows = T
275
+ )
274
276
275
277
newGenes.counts <- gene_expression_matrix %> %
276
278
left_join(. , genes.retrieved , by = c(" gene_name" = " MGI.symbol" )) %> %
@@ -289,32 +291,33 @@ mouse_genes_to_human <- function(gene_expression_matrix, mirror = "www", other_a
289
291
290
292
message(paste0(" ATTENTION: Only the " , fraction , " % of genes was maintained" ))
291
293
},
292
- error = function (e ){
293
- print(' Cannot connect to ENSEMBL. Using alternative method. This will take some time.' )
294
-
295
- if (manual_annot ){
294
+ error = function (e ) {
295
+ print(" Cannot connect to ENSEMBL. Using alternative method. This will take some time." )
296
296
297
+ if (manual_annot ) {
297
298
# Code adapted from: https://support.bioconductor.org/p/129636/#9144606
298
299
299
- mouse_human_genes = read.csv(" http://www.informatics.jax.org/downloads/reports/HOM_MouseHumanSequence.rpt" ,sep = " \t " )
300
+ mouse_human_genes <- read.csv(" http://www.informatics.jax.org/downloads/reports/HOM_MouseHumanSequence.rpt" , sep = " \t " )
300
301
301
- find_corr_gene <- function (gene , mouse_human_genes_df ){
302
- class_key = (mouse_human_genes_df %> %
303
- filter(Symbol == gene & Common.Organism.Name == " mouse, laboratory" ))[[' DB.Class.Key' ]]
304
- if (! identical(class_key , integer(0 )) ) {
302
+ find_corr_gene <- function (gene , mouse_human_genes_df ) {
303
+ class_key <- (mouse_human_genes_df %> %
304
+ filter(Symbol == gene & Common.Organism.Name == " mouse, laboratory" ))[[" DB.Class.Key" ]]
305
+ if (! identical(class_key , integer(0 ))) {
305
306
output <- NULL
306
- human_genes = (mouse_human_genes_df %> % filter(DB.Class.Key == class_key & Common.Organism.Name == " human" ))[," Symbol" ]
307
- for (human_gene in human_genes ){
308
- output = append(output , human_gene )
307
+ human_genes <- (mouse_human_genes_df %> % filter(DB.Class.Key == class_key & Common.Organism.Name == " human" ))[, " Symbol" ]
308
+ for (human_gene in human_genes ) {
309
+ output <- append(output , human_gene )
309
310
}
310
- if (! is.null(output )){
311
+ if (! is.null(output )) {
311
312
return (
312
313
data.frame (
313
- ' human_gene' = output ,
314
- ' mouse_gene' = gene ))
314
+ " human_gene" = output ,
315
+ " mouse_gene" = gene
316
+ )
317
+ )
315
318
}
316
-
317
- } }
319
+ }
320
+ }
318
321
319
322
genes.retrieved <- map_dfr(gene.names.mouse , function (x ) find_corr_gene(x , mouse_human_genes ))
320
323
@@ -328,9 +331,9 @@ mouse_genes_to_human <- function(gene_expression_matrix, mirror = "www", other_a
328
331
round(. , 1 )
329
332
330
333
message(paste0(" ATTENTION: Only the " , fraction , " % of genes was maintained" ))
331
-
332
334
}
333
- })
335
+ }
336
+ )
334
337
335
338
return (newGenes.counts )
336
339
}
0 commit comments