saschajung / Intercom

Creative Commons Attribution 4.0 International
0 stars 0 forks source link

Global Variable error help, please? #1

Closed Pancreas-Pratik closed 3 years ago

Pancreas-Pratik commented 3 years ago

Hi Dr. Jung,

I am receiving an error message when using InterCom:

Error in registerNames(names, package, ".__global__", add) : 
  The namespace for package "InterCom" is locked; no changes in the global variables list may be made.

I was hoping you could, please, help find a solution?

I did some googling and found that there are two ways around this, I think. https://stackoverflow.com/questions/30959050/why-am-i-getting-namespace-is-locked-in-rstudio This one says to place add=F like so:

  utils::globalVariables(c("Background_signaling_interactome", "LR", "Ligands", "Receptors",
                            "TF_TF_interactions", "dummy.var", "intermediates",
                             "non_interface_TFs"), package="InterCom", add=FALSE)

However that was unsuccessful.

The other option is on this page: https://github.com/STAT545-UBC/Discussion/issues/451 I am not sure if that page provides an actual solution. Other than the first solution.

The data I am using is the one from the recent nature paper featuring your package. https://human-pancreas-dev.cells.ucsc.edu Here is an example of the full example:

mat <- read.table("~/Projects/fetal-pancreas-7-10wpc/exprMatrix.tsv", header=T, sep="\t")
meta <- read.table("~/Projects/fetal-pancreas-7-10wpc/meta.tsv", header=T, sep="\t", as.is=T, row.names=1)
anno.tbl <- tibble::rownames_to_column(meta, "cellnames")
anno.tbl$nCount_RNA <- NULL
anno.tbl$nFeature_RNA <- NULL
anno.tbl$phase <- NULL
anno.tbl$age <- NULL
library(InterCom)
InterCom(mat,
         anno.tbl,
         "HUMAN",
         sighot.cutoff=0.1,
         sighot.percentile=70,
         consv.thrs=0.05,
         ncores=16,
         sig.cutoff=0.9,
         z.score.cutoff=2,
         "Pancreas",
         'temp',
         "~/Projects/fetal-pancreas-7-10wpc/InterCom/"
)
Creating input parameters file

Tissue :  Pancreas 
 Preparing data
Error in registerNames(names, package, ".__global__", add) : 
  The namespace for package "InterCom" is locked; no changes in the global variables list may be made.
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] InterCom_0.1

loaded via a namespace (and not attached):
 [1] igraph_1.2.6     Rcpp_1.0.6       magrittr_2.0.1   tidyselect_1.1.1 lattice_0.20-44 
 [6] R6_2.5.0         rlang_0.4.11     fansi_0.5.0      stringr_1.4.0    plyr_1.8.6      
[11] dplyr_1.0.6      tools_4.1.0      parallel_4.1.0   grid_4.1.0       utf8_1.2.1      
[16] RSpectra_0.16-0  DBI_1.1.1        ellipsis_0.3.2   assertthat_0.2.1 tibble_3.1.2    
[21] lifecycle_1.0.0  crayon_1.4.1     Matrix_1.3-3     purrr_0.3.4      reshape2_1.4.4  
[26] vctrs_0.3.8      glue_1.4.2       taRifx_1.0.6.2   stringi_1.6.2    compiler_4.1.0  
[31] pillar_1.6.1     generics_0.1.0   pkgconfig_2.0.3 

Thank you again for your work on this project. I am excited to use InterCom!

saschajung commented 3 years ago

Thanks for flagging this issue, somehow i never experienced this before but could reproduce it with your example. I just committed a fix for this, which does not rely on any global variables anymore but only creates package global variables. That should do the trick.

Let me nevertheless make a comment regarding the script you were using. The data you referenced contains Ensembl gene Id's, which are not directly usable by InterCom. Instead, you must supply gene symbols, since all the background data is built solely on gene symbols. Therefore, please make sure to transform the input matrix to carry counts based on gene symbols before invoking InterCom.

Having said that, there are a few considerations here, which determine the output of InterCom:

  1. Depending on how you map the Ensembl Id's to gene symbols, the number of actually mapping genes varies. Especially the Markov Chain model of intracellular signaling is very sensitive to this, as it is conceptually not the same whether a gene is not in the dataset at all or it is consistently not expressed. Thus, it matters how Id mapping is performed. For the results shown in the manuscript, we used the org.Hs.eg.db R-package version 3.10 (See here). Newer versions of this package give different mappings and could change the resulting cell-cell interactome slightly.
  2. Multiple Ensembl Id's map to the same gene symbol making it necessary to aggegrate the resulting duplicate symbols. I'd propose to do this by using the maximum-value for aggregation.

In any case, i'll upload a script for reproducing the results in the paper in a couple of days.

Please let me know whether the initial issue of the global variables is fixed and open another issue for further inquiries not related to this.

Pancreas-Pratik commented 3 years ago

Hi Dr. Chung - the initial issue of global variables is fixed. Thank you.