WWXkenmo / ICAnet

Independent Component Analysis decipher functional modules for better cell clustering and annotation
15 stars 1 forks source link

get errors at getPPI_String and PPI.network_BioGrid #3

Closed Roger-GOAT closed 3 years ago

Roger-GOAT commented 3 years ago

Hi team, thank you for the package. When I run PPI.network_STRING and PPI.network_BioGrid get errors. My species is mouse and I get a result is 10090.

> hs_network_matrix <- getPPI_String(pancreas,species = 10090)
trying URL 'https://stringdb-static.org/download/protein.links.v11.0/10090.protein.links.v11.0.txt.gz'
Content type 'application/octet-stream' length 70223084 bytes (67.0 MB)
==================================================
downloaded 67.0 MB

trying URL 'https://stringdb-static.org/download/protein.info.v11.0/10090.protein.info.v11.0.txt.gz'
Content type 'application/octet-stream' length 1834498 bytes (1.7 MB)
==================================================
downloaded 1.7 MB

Warning messages:
1: replacing previous import ‘clusterProfiler::simplify’ by ‘igraph::simplify’ when loading ‘RSCORE’ 
2: replacing previous import ‘igraph::simplify’ by ‘propr::simplify’ when loading ‘RSCORE’ 
3: replacing previous import ‘igraph::get.vertex.attribute’ by ‘network::get.vertex.attribute’ when loading ‘RSCORE’ 
> pancreas <- RunICAnet(pancreas,ica.filter$ica.filter, PPI.net = hs_network_matrix, W.top=2,aucMaxRank = 300,ModuleSignificance=FALSE,scale=FALSE)
Error in intI(i, n = d[1], dn[[1]], give.dn = FALSE) : 
  no 'dimnames[[.]]': cannot use character indexing
> sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so

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

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

other attached packages:
 [1] RSCORE_0.1.0           clusterProfiler_3.18.0
 [3] RcisTarget_1.10.0      AUCell_1.13.0         
 [5] FNN_1.1.3              RISC_1.0              
 [7] velocyto.R_0.6         Matrix_1.3-2          
 [9] SeuratWrappers_0.3.0   SeuratDisk_0.0.0.9019 
[11] forcats_0.5.0          purrr_0.3.4           
[13] readr_1.4.0            tidyr_1.1.3           
[15] tibble_3.1.0           tidyverse_1.3.0       
[17] dplyr_1.0.5            dbplyr_2.0.0          
[19] harmony_1.0            Rcpp_1.0.6            
[21] cowplot_1.1.1          gmodels_2.18.1        
[23] igraph_1.2.6           stringr_1.4.0         
[25] gatepoints_0.1.4       circlize_0.4.12       
[27] patchwork_1.1.1        sctransform_0.3.2     
[29] ggplot2_3.3.3          SeuratObject_4.0.0    
[31] Seurat_4.0.1.999       devtools_2.3.2        
[33] usethis_2.0.0

Here is the full code:

##Integrate analysis of pancreatic islet scRNA-seq dataset--------
library(doParallel)
library(Seurat)
library(cowplot)
library(ica)
library(ICAnet)
library(SingleCellExperiment)
pancreas <- readRDS("~/result/allday/scRNA.null.rds")
pancreas.list <- SplitObject(pancreas, split.by="orig.ident")
for(i in 1:length(pancreas.list)) {
  pancreas.list[[i]] <- NormalizeData(pancreas.list[[i]],verbose=FALSE)
  pancreas.list[[i]] <- FindVariableFeatures(pancreas.list[[i]],selection.method="vst",nfeature=8000,verbose=FALSE)
}
##Select integrate features
pancreas.feature <- SelectIntegrationFeatures(object.list = pancreas.list,nfeatures = 3000)
###integrate pancreas list
pancreas.all <- pancreas.list[[1]]
pancreas.all <- GetAssayData(pancreas.all)[pancreas.feature,]
for(i in 2:length(table(scRNA$orig.ident))){
  pancreas.set <- pancreas.list[[i]]
  pancreas.set <- GetAssayData(pancreas.set)[pancreas.feature,]
  pancreas.all <- cbind(pancreas.all,pancreas.set[pancreas.feature,])
}
scRNA[['Consensus.RNA']] <- CreateAssayObject(pancreas.all)
DefaultAssay(scRNA) <- "Consensus.RNA"
##Stage II:------------
pancreas <- ScaleData(pancreas)
pancreas <- RunPCA(pancreas, npcs =50,verbose=FALSE,features=rownames(pancreas))
ElbowPlot(pancreas,reduction = "pca")
pancreas <- RunUMAP(pancreas, reduction = "pca", dims = 1:20, reduction.name = "umap",  reduction.key = "umap_") 
p1 <- Seurat::DimPlot(pancreas, reduction = 'umap', group.by = 'orig.ident',label=T)
pancreas <- FindNeighbors(pancreas)
pancreas <- FindClusters(pancreas, resolution = 1, algorithm = 1)
p2 <- Seurat::DimPlot(pancreas, reduction = 'umap', group.by = 'seurat_clusters',label=1)+NoLegend()
plot_grid(p1,p2)
pancreas$batch <- pancreas$orig.ident
pancreas$celltype <- pancreas$seurat_clusters
ica.pancreas <- ICAcomputing(pancreas, ICA.type="JADE",two.stage = FALSE,global.mode=FALSE,center=FALSE,scale=TRUE)
ica.filter <- CrossBatchGrouping(ica.pancreas$ica.pooling,cor="spearman",Unique.Preservation=FALSE)
##Stage III--------------
library(RSCORE)
hs_network_matrix <- getPPI_String(pancreas,species = 10090)
pancreas <- RunICAnet(pancreas,ica.filter$ica.filter, PPI.net = hs_network_matrix, W.top=2,aucMaxRank = 300,ModuleSignificance=FALSE,scale=FALSE)
WWXkenmo commented 3 years ago

Hi ! After checking your code, here is my ideas about possible issues.. 1) DefaultAssay(scRNA) <- "Consensus.RNA", where is the "scRNA" object come from? probably you mean DefaultAssay(pancreas) <- "Consensus.RNA" ? coz ICAcomputing need to run on the "Consensus.RNA" assay 2) Please check whether the dimensions of hs_network_matrix is normal, and whether the rownames of ica.filter$ica.filter and hs_network_matrix is the same. (e.g. gene symbol). If ica.filter$ica.filter or hs_network_matrix has no rownames it would return the errors. Some people have reported to me that when they run getPPI_String function provided by RSCORE will return some errors. Please check the above possible issues, then return to me, I will solve the bug as soon as possible!

Roger-GOAT commented 3 years ago

Thanks for the reply!

  1. Yes. I do run "DefaultAssay(pancreas) <- "Consensus.RNA"
  2. And yes, the hs_network_matrix is empty.
    > dim(hs_network_matrix)
    [1] 0 0
    Warning messages:
    1: replacing previous import ‘clusterProfiler::simplify’ by ‘igraph::simplify’ when loading ‘RSCORE’ 
    2: replacing previous import ‘igraph::simplify’ by ‘propr::simplify’ when loading ‘RSCORE’ 
    3: replacing previous import ‘igraph::get.vertex.attribute’ by ‘network::get.vertex.attribute’ when loading ‘RSCORE’ 
    > head(rownames(ica.filter$ica.filter),10)
    [1] "Lcn2"    "Cd14"    "Ackr1"   "Mgp"    
    [5] "Fbln5"   "Cytl1"   "Cxcl1"   "Ptgs2"  
    [9] "Scgb3a1" "Ifitm1"
    > rownames(hs_network_matrix)
    NULL

    My server's network is bad and sometimes it can't download the whole 10090.protein.links.v11.0.txt.gz. and the file maybe damaged. I had downloaded the .gz locally and upload it to the server. How to change the R code? Is this reason that the hs_network_matrix is NULL. The hs_network_matrix look like this. image

WWXkenmo commented 3 years ago

I am so sorry for response so late coz I am very busy this week. I have fixed the bug, and uploaded the fixed getPPI_String.R file, you can check it through this link https://github.com/WWXkenmo/ICAnet/blob/master/getPPI_String.R The getPPI_Biogrid will be fixed later, I will upload it immediately. hope this will helpful, if you encounter any questions, pose you issue with no hesitate.

K. W.

Roger-GOAT commented 3 years ago

It is fixed! Great job!