6060# converting. helpers below wrap the recommended API.
6161
6262
63- def _to_r (obj ):
64- """Convert a pandas object to an R object using the current converter."""
65- with conversion .localconverter (ro .default_converter + pandas2ri .converter ):
66- return conversion .py2rpy (obj )
67-
68-
6963def _to_py (obj ):
7064 """Convert an R object to a pandas/numpy equivalent."""
7165 with conversion .localconverter (ro .default_converter + pandas2ri .converter ):
@@ -175,7 +169,6 @@ def plot_r_function(func_name: str, *args, width=800, height=600, filename=None,
175169
176170def ensure_bioc_installed () -> None :
177171 """Install Bioconductor's package manager if it is not already present."""
178- utils = importr ("utils" )
179172 biocinstaller = "BiocManager"
180173 if not isinstalled (biocinstaller ):
181174 ro .r ('install.packages("{0}")' .format (biocinstaller ))
@@ -189,22 +182,17 @@ def install_markeR() -> None:
189182 the package should be loadable via `importr("markeR")`.
190183 """
191184 ensure_bioc_installed ()
192- # use importr to check presence rather than only the isinstalled helper
193- try :
194- importr ("markeR" )
195- except Exception :
196- # attempt installation if import failed
185+ if not isinstalled ("markeR" ):
197186 ro .r ('BiocManager::install("markeR", ask=FALSE, update=FALSE)' )
198- # load into namespace for side effects
199- ro .r ('library(markeR)' )
187+ ro .r ('library(markeR)' )
200188
201189
202190def get_markeR_functions () -> ro .Environment :
203191 """Return the markeR namespace so that functions can be accessed conveniently.
204192
205193 Example:
206194 mark = get_markeR_functions()
207- imputed = mark.rgImpute(... )
195+ scores = mark.CalculateScores(data=counts, metadata=metadata, gene_sets=genesets, method="logmedian" )
208196 """
209197 install_markeR ()
210198 # importing via importr is more reliable than accessing `ro.r['markeR']`.
@@ -330,4 +318,4 @@ def tutorial_benchmark(output_file=None):
330318 print (" example: python markeR_to_python.py --tutorial --output my_plot.png" )
331319 else :
332320 print ("usage: python markeR_to_python.py --tutorial [--output FILENAME]" )
333- print ("See the module docstring for more details." )
321+ print ("See the module docstring for more details." )
0 commit comments