-
Notifications
You must be signed in to change notification settings - Fork 7
/
dependency_troubleshoot.py
executable file
·53 lines (49 loc) · 1.96 KB
/
dependency_troubleshoot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#Script to test if all necessary dependencies have been installed:
import sys, importlib
python_packages =["copy","fcsparser","fcswrite","itertools","natsort","numpy",
"pandas","plotly","pynndescent","re","rpy2","scprep",
"sklearn","subprocess","umap"]
#copy, itertools, re, subprocess -> come with Python
count=0
for i in python_packages:
try:
importlib.import_module(i)
count +=1
except:
print ("WARNING!: Python package ",i, " is not installed properly. Please install it manually")
if len(python_packages)==count:
print("All Python packages are installed!")
try:
from rpy2.robjects import r
except:
sys.exit("ERROR: rpy2 python package is missing and we can not test for missing R packages")
r('''
#Packages to use:
list.of.packages <- c(
"ComplexHeatmap",
"DT",
"factoextra",
"FactoMineR",
"flowCore",
"GGally",
"ggrepel",
"Hmisc",
"MASS",
"matrixStats",
"plotly",
"psych",
"RColorBrewer",
"shiny",
"tidyverse"
)
# check if pkgs are already installed:
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) {
print(paste0("WARNING!: Missing R package(s): ", new.packages))
# print("Attempting to install missing R package(s)...")
# install.packages(new.packages, repos = "http://cran.us.r-project.org")
# lapply(list.of.packages, require, character.only = TRUE) #Load packages
} else {
print("All R packages are installed!")
}
''')