Palantir icon indicating copy to clipboard operation
Palantir copied to clipboard

Issue with gene expression trends

Open Kristina1234444 opened this issue 1 year ago • 6 comments

I am trying to run the gene expression trends, however, I am getting the following error message with the R package "gam". I installed the package, but still the same issue occurs even after I installed it. Could you please be able to let me know how to fix the issue? I am running everying on the command prompt by calling jupyter notebook. Here is the error message that I am getting:

PackageNotInstalledError Traceback (most recent call last) Input In [3], in <cell line: 4>() 1 genes = ['1', '2', '3', '4'] 2 imp_df = pd.DataFrame(ad[:, genes].layers['MAGIC_imputed_data'], 3 index=ad.obs_names, columns=genes) ----> 4 gene_trends = palantir.presults.compute_gene_trends( pr_res, imp_df.loc[:, genes])

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\palantir\presults.py:99, in compute_gene_trends(pr_res, gene_exprs, lineages, n_jobs) 93 raise RuntimeError( 94 "R installation is necessary for computing gene expression trends.
95 \nPlease install R and try again" 96 ) 98 try: ---> 99 rgam = importr("gam") 100 except embedded.RRuntimeError: 101 raise RuntimeError( 102 'R package "gam" is necessary for computing gene expression trends.
103 \nPlease install gam from https://cran.r-project.org/web/packages/gam/ and try again' 104 )

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\rpy2\robjects\packages.py:472, in importr(name, lib_loc, robject_translations, signature_translation, suppress_messages, on_conflict, symbol_r2python, symbol_resolve, data) 440 """ Import an R package. 441 442 Arguments: (...) 468 469 """ 471 if not isinstalled(name, lib_loc=lib_loc): --> 472 raise PackageNotInstalledError( 473 'The R package "%s" is not installed.' % name 474 ) 476 if suppress_messages: 477 ok = quiet_require(name, lib_loc=lib_loc)

PackageNotInstalledError: The R package "gam" is not installed.

Kristina1234444 avatar Sep 15 '22 15:09 Kristina1234444

Can you please try using the Github main branch? We have updated the repository to use pygam instead of R gam

ManuSetty avatar Sep 17 '22 04:09 ManuSetty

Thanks, I installed the pygam package, however, the exact same issue appears. It says that I need to install gam. Could you please suggest any solutions to this issue? I am running everything on jupyter notebook, do I need to install R in the command prompt and try to run the commands again? Thank you.

Here is my code: genes = ['1', '2', '3', '4'] imp_df = pd.DataFrame(ad[:, genes].layers['MAGIC_imputed_data'], index=ad.obs_names, columns=genes) gene_trends = palantir.presults.compute_gene_trends( pr_res, imp_df.loc[:, genes])

Here is the same output error message: "Unable to determine R home: [WinError 2] The system cannot find the file specified"

Kristina1234444 avatar Sep 19 '22 15:09 Kristina1234444

This is surprising since R should no longer be required. Do you have a full traceback that you can share?

ManuSetty avatar Sep 22 '22 16:09 ManuSetty

Here is my code: genes = ['1', '2', '3', '4'] imp_df = pd.DataFrame(ad[:, genes].layers['MAGIC_imputed_data'], index=ad.obs_names, columns=genes) gene_trends = palantir.presults.compute_gene_trends( pr_res, imp_df.loc[:, genes])

Error message below: PackageNotInstalledError Traceback (most recent call last) Input In [3], in <cell line: 4>() 1 genes = ['1', '2', '3', '4'] 2 imp_df = pd.DataFrame(ad[:, genes].layers['MAGIC_imputed_data'], 3 index=ad.obs_names, columns=genes) ----> 4 gene_trends = palantir.presults.compute_gene_trends( pr_res, imp_df.loc[:, genes])

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\palantir\presults.py:99, in compute_gene_trends(pr_res, gene_exprs, lineages, n_jobs) 93 raise RuntimeError( 94 "R installation is necessary for computing gene expression trends. 95 \nPlease install R and try again" 96 ) 98 try: ---> 99 rgam = importr("gam") 100 except embedded.RRuntimeError: 101 raise RuntimeError( 102 'R package "gam" is necessary for computing gene expression trends. 103 \nPlease install gam from https://cran.r-project.org/web/packages/gam/ and try again' 104 )

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\rpy2\robjects\packages.py:472, in importr(name, lib_loc, robject_translations, signature_translation, suppress_messages, on_conflict, symbol_r2python, symbol_resolve, data) 440 """ Import an R package. 441 442 Arguments: (...) 468 469 """ 471 if not isinstalled(name, lib_loc=lib_loc): --> 472 raise PackageNotInstalledError( 473 'The R package "%s" is not installed.' % name 474 ) 476 if suppress_messages: 477 ok = quiet_require(name, lib_loc=lib_loc)

PackageNotInstalledError: The R package "gam" is not installed.

Any suggestions how to fix this error will be highly appreciated.

Kristina1234444 avatar Sep 22 '22 16:09 Kristina1234444

Thank you - Looks like the installation is still on the previous version. Can you please try installing the main branch again? You will need to clone the repository from GitHub, install again and then restart your notebooks.

ManuSetty avatar Sep 22 '22 16:09 ManuSetty

Could you please be able to give me instructions of how to " installing the main branch again"? Thank you!

Kristina1234444 avatar Sep 22 '22 16:09 Kristina1234444

You can try the following:

Change your conda environment appropriately using conda activate <env name>

Following this git clone https://github.com/dpeerlab/Palantir.git cd Palantir pip install .

This should help you get set up with the main branch of Palantir.

ManuSetty avatar Sep 25 '22 21:09 ManuSetty