BayesPrism icon indicating copy to clipboard operation
BayesPrism copied to clipboard

Errors when running BayesPrism with gene symbles.

Open Sphingosine opened this issue 3 years ago • 1 comments

Hi,

I was running BayesPrism using gene symbols and met this error when running functions plot.scRNA.outlier and plot.bulk.outlier:

" Error in input.genes.short %in% gene.df[gene.df[, 1] == gene.group.i, : object 'input.genes.short' not found "

I found it's due to the function "assign.category" in "process_input.R" and made a very slight change to make it work: #detect if EMSEMBLE ID (starts with ENS) or gene symbol is used if( sum(substr(input.genes,1,3)=="ENS")> length(input.genes)*0.8 ){ cat("EMSEMBLE IDs detected.\n") input.genes.short <- unlist(lapply(input.genes, function(gene.id) strsplit(gene.id,split="\.")[[1]][1])) gene.df <- gene.list[,c(1,2)] gene.group.matrix <- do.call(cbind.data.frame, lapply(unique(gene.df[,1]), function(gene.group.i) input.genes.short %in% gene.df[gene.df[,1]== gene.group.i,2])) } else{ cat("Gene symbols detected. Recommend to use EMSEMBLE IDs for more unique mapping.\n") gene.df <- gene.list[,c(1,3)] gene.group.matrix <- do.call(cbind.data.frame, lapply(unique(gene.df[,1]), function(gene.group.i) input.genes %in% gene.df[gene.df[,1]== gene.group.i,2])) }

Hope it helps : )

Thanks! Shuai

Sphingosine avatar Jun 22 '22 08:06 Sphingosine

Hi Shuai,

Thank you very much for your catch. It is fixed now.

Best,

Tinyi

On Wed, Jun 22, 2022 at 4:42 AM SG-ShuaiGuo @.***> wrote:

Hi,

I was running BayesPrism using gene symbols and met this error when running functions plot.scRNA.outlier and plot.bulk.outlier:

" Error in input.genes.short %in% gene.df[gene.df[, 1] == gene.group.i, : object 'input.genes.short' not found "

I found it's due to the function "assign.category" in "process_input.R" and made a very slight change to make it work:

  • #detect if EMSEMBLE ID (starts with ENS) or gene symbol is used
  • if( sum(substr(input.genes,1,3)=="ENS")> length(input.genes)*0.8 ){
 cat("EMSEMBLE IDs detected.\n")
 input.genes.short <- unlist(lapply(input.genes, function(gene.id) strsplit(gene.id,split="\\.")[[1]][1]))
 gene.df <- gene.list[,c(1,2)]
 gene.group.matrix <- do.call(cbind.data.frame, lapply(unique(gene.df[,1]),
                                                       function(gene.group.i) input.genes.short %in% gene.df[gene.df[,1]== gene.group.i,2]))
  • }
  • else{
 cat("Gene symbols detected. Recommend to use EMSEMBLE IDs for more unique mapping.\n")
 gene.df <- gene.list[,c(1,3)]
 gene.group.matrix <- do.call(cbind.data.frame, lapply(unique(gene.df[,1]),
                                                       function(gene.group.i) input.genes %in% gene.df[gene.df[,1]== gene.group.i,2]))
  • }

Hope it helps : )

Thanks! Shuai

— Reply to this email directly, view it on GitHub https://github.com/Danko-Lab/BayesPrism/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4NHSZFJUICEEBUPKLIYUDVQLGYLANCNFSM5ZPL5ZUA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

tinyi avatar Jun 22 '22 18:06 tinyi