-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R interface #60
Open
astamm
wants to merge
6
commits into
GUDHI:master
Choose a base branch
from
astamm:r-interface
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
R interface #60
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7499e6e
First draft for r-interface tutos.
astamm 03ee66d
Discard hmtl files from git versioning.
astamm 8a59e0f
Do not render unmodified qmds.
astamm 049553b
Remove section numbering.
astamm 198036a
Remove section numbering everywhere, and author from README.
astamm f96d4c0
Updated README.
astamm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
.ipynb_checkpoints | ||
__pycache__ | ||
.Rproj.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/.quarto/ | ||
*html | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
|
||
<!-- README.md is generated from README.qmd. Please edit that file --> | ||
|
||
# Setup instructions for using GUDHI from R | ||
|
||
<!-- badges: start --> | ||
<!-- badges: end --> | ||
|
||
## The [**reticulate**](https://rstudio.github.io/reticulate/) package | ||
|
||
The [**reticulate**](https://rstudio.github.io/reticulate/) package | ||
provides a comprehensive set of tools for interoperability between | ||
Python and R. The package includes facilities for: | ||
|
||
- Calling Python from R in a variety of ways including R Markdown, | ||
sourcing Python scripts, importing Python modules, and using Python | ||
interactively within an R session. | ||
- Translation between R and Python objects (for example, between R and | ||
Pandas data frames, or between R matrices and NumPy arrays). | ||
- Flexible binding to different versions of Python including virtual | ||
environments and Conda environments. | ||
|
||
[**reticulate**](https://rstudio.github.io/reticulate/) embeds a Python | ||
session within your R session, enabling seamless, high-performance | ||
interoperability. If you are an R developer that uses Python for some of | ||
your work or a member of data science team that uses both languages, | ||
[**reticulate**](https://rstudio.github.io/reticulate/) can dramatically | ||
streamline your workflow. | ||
|
||
## Bring GUDHI into R | ||
|
||
- First, you’ll want to install and load the | ||
[**reticulate**](https://rstudio.github.io/reticulate/) package into | ||
your session: | ||
|
||
``` r | ||
# install.packages("reticulate") | ||
library(reticulate) | ||
``` | ||
|
||
- Next, the fastest way to get you set up to use Python from R with | ||
[**reticulate**](https://rstudio.github.io/reticulate/) is to use | ||
the `install_miniconda()` utility function which is included in the | ||
[**reticulate**](https://rstudio.github.io/reticulate/) package. In | ||
details, use something like: | ||
|
||
``` r | ||
install_miniconda() | ||
``` | ||
|
||
- Next, it is recommended that you create a virtual conda environment | ||
in which you’ll install all required Python packages. This can be | ||
achieved using the `reticulate::conda_create()` function as follows: | ||
|
||
``` r | ||
version <- "3.9.6" | ||
conda_create("r-reticulate", python_version = version) | ||
``` | ||
|
||
- Next, you can seamlessly install all the Python packages you need by | ||
calling the `conda_install()` function. For instance, to use Gudhi, | ||
you would do something like: | ||
|
||
``` r | ||
conda_install("scikit-learn", envname = "r-reticulate") | ||
conda_install("gudhi", envname = "r-reticulate") | ||
``` | ||
|
||
This is a setup that you ought to do only once (unless you want to | ||
change your Python version for some reason). | ||
|
||
If you want to check your Python configuration, you can do: | ||
|
||
``` r | ||
py_config() | ||
#> python: /Users/stamm-a/Library/r-miniconda/envs/r-reticulate/bin/python3.9 | ||
#> libpython: /Users/stamm-a/Library/r-miniconda/envs/r-reticulate/lib/libpython3.9.dylib | ||
#> pythonhome: /Users/stamm-a/Library/r-miniconda/envs/r-reticulate:/Users/stamm-a/Library/r-miniconda/envs/r-reticulate | ||
#> version: 3.9.6 | packaged by conda-forge | (default, Jul 11 2021, 03:36:15) [Clang 11.1.0 ] | ||
#> numpy: /Users/stamm-a/Library/r-miniconda/envs/r-reticulate/lib/python3.9/site-packages/numpy | ||
#> numpy_version: 1.22.4 | ||
#> | ||
#> NOTE: Python version was forced by RETICULATE_PYTHON | ||
``` | ||
|
||
# Organisation | ||
|
||
## File hierarchy | ||
|
||
This folder contains a number of [Quarto](https://quarto.org) documents | ||
contributed with the purpose of showing how | ||
[`R`](https://www.r-project.org) can be used to enhance statistical | ||
analysis of topological data produced via | ||
[Gudhi](https://gudhi.inria.fr). Each tutorial is hosted in its own | ||
folder which is organised as follows: | ||
|
||
- The Quarto document with extension `.qmd` which is the main file | ||
that a developer is supposed to contribute. In this document, there | ||
is a YAML header in which the contributor can specify various output | ||
formats by adding | ||
|
||
``` yaml | ||
#| eval: false | ||
format: | ||
html: default | ||
gfm: default | ||
pdf: default | ||
``` | ||
|
||
The complete list of possible output formats: | ||
<https://quarto.org/docs/output-formats/all-formats.html>. | ||
|
||
- A Github-flavored markdown (GMF) document with extension `.md` which | ||
enables nice visualization of the notebook directly in the Github | ||
web interface. | ||
|
||
- A folder containing useful libs and resources to display the GMF | ||
document. | ||
|
||
## Contributing | ||
|
||
If you want to contribute, you should | ||
|
||
1. Fork the `TDA-tutorials` repo | ||
2. Open the RStudio project in | ||
`TDA-tutorials/r-interface/r-interface.Rproj`. | ||
3. When opened in RStudio, the working directory should now be | ||
`TDA-tutorials/r-interface/` in which you can now create a folder | ||
with evocative name to put the Quarto document describing the | ||
analysis you want to share. | ||
- Note: you can use the same YAML header as in | ||
`reticulate/reticulate.qmd` as a number of presets for rendering | ||
are made into the `_quarto.yml` file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
--- | ||
format: gfm | ||
toc: false | ||
--- | ||
|
||
<!-- README.md is generated from README.qmd. Please edit that file --> | ||
|
||
```{r} | ||
#| label: setup | ||
#| include: false | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>" | ||
) | ||
``` | ||
|
||
# Setup instructions for using GUDHI from R | ||
|
||
<!-- badges: start --> | ||
|
||
<!-- badges: end --> | ||
|
||
## The [**reticulate**](https://rstudio.github.io/reticulate/) package | ||
|
||
The [**reticulate**](https://rstudio.github.io/reticulate/) package | ||
provides a comprehensive set of tools for interoperability between | ||
Python and R. The package includes facilities for: | ||
|
||
- Calling Python from R in a variety of ways including R Markdown, | ||
sourcing Python scripts, importing Python modules, and using Python | ||
interactively within an R session. | ||
- Translation between R and Python objects (for example, between R and | ||
Pandas data frames, or between R matrices and NumPy arrays). | ||
- Flexible binding to different versions of Python including virtual | ||
environments and Conda environments. | ||
|
||
[**reticulate**](https://rstudio.github.io/reticulate/) embeds a Python | ||
session within your R session, enabling seamless, high-performance | ||
interoperability. If you are an R developer that uses Python for some of | ||
your work or a member of data science team that uses both languages, | ||
[**reticulate**](https://rstudio.github.io/reticulate/) can dramatically | ||
streamline your workflow. | ||
|
||
## Bring GUDHI into R | ||
|
||
- First, you'll want to install and load the | ||
[**reticulate**](https://rstudio.github.io/reticulate/) package into | ||
your session: | ||
|
||
```{r} | ||
# install.packages("reticulate") | ||
library(reticulate) | ||
``` | ||
|
||
- Next, the fastest way to get you set up to use Python from R with | ||
[**reticulate**](https://rstudio.github.io/reticulate/) is to use | ||
the `install_miniconda()` utility function which is included in the | ||
[**reticulate**](https://rstudio.github.io/reticulate/) package. In | ||
details, use something like: | ||
|
||
```{r} | ||
#| eval: false | ||
install_miniconda() | ||
``` | ||
|
||
- Next, it is recommended that you create a virtual conda environment | ||
in which you'll install all required Python packages. This can be | ||
achieved using the `reticulate::conda_create()` function as follows: | ||
|
||
```{r} | ||
#| eval: false | ||
version <- "3.9.6" | ||
conda_create("r-reticulate", python_version = version) | ||
``` | ||
|
||
- Next, you can seamlessly install all the Python packages you need by | ||
calling the `conda_install()` function. For instance, to use Gudhi, | ||
you would do something like: | ||
|
||
```{r} | ||
#| eval: false | ||
conda_install("scikit-learn", envname = "r-reticulate") | ||
conda_install("gudhi", envname = "r-reticulate") | ||
``` | ||
|
||
This is a setup that you ought to do only once (unless you want to | ||
change your Python version for some reason). | ||
|
||
If you want to check your Python configuration, you can do: | ||
|
||
```{r} | ||
py_config() | ||
``` | ||
|
||
# Organisation | ||
|
||
## File hierarchy | ||
|
||
This folder contains a number of [Quarto](https://quarto.org) documents | ||
contributed with the purpose of showing how | ||
[`R`](https://www.r-project.org) can be used to enhance statistical | ||
analysis of topological data produced via | ||
[Gudhi](https://gudhi.inria.fr). Each tutorial is hosted in its own | ||
folder which is organised as follows: | ||
|
||
- The Quarto document with extension `.qmd` which is the main file | ||
that a developer is supposed to contribute. In this document, there | ||
is a YAML header in which the contributor can specify various output | ||
formats by adding | ||
|
||
``` yaml | ||
#| eval: false | ||
format: | ||
html: default | ||
gfm: default | ||
pdf: default | ||
``` | ||
|
||
The complete list of possible output formats: | ||
<https://quarto.org/docs/output-formats/all-formats.html>. | ||
|
||
- A Github-flavored markdown (GMF) document with extension `.md` which | ||
enables nice visualization of the notebook directly in the Github | ||
web interface. | ||
|
||
- A folder containing useful libs and resources to display the GMF | ||
document. | ||
|
||
## Contributing | ||
|
||
If you want to contribute, you should | ||
|
||
1. Fork the `TDA-tutorials` repo | ||
2. Open the RStudio project in | ||
`TDA-tutorials/r-interface/r-interface.Rproj`. | ||
3. When opened in RStudio, the working directory should now be | ||
`TDA-tutorials/r-interface/` in which you can now create a folder | ||
with evocative name to put the Quarto document describing the | ||
analysis you want to share. | ||
- Note: you can use the same YAML header as in | ||
`reticulate/reticulate.qmd` as a number of presets for rendering | ||
are made into the `_quarto.yml` file. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could add somewhere in this global |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"hash": "9629af67199513e45263219d8338c33e", | ||
"result": { | ||
"markdown": "---\nformat: gfm\ntoc: false\n---\n\n\n<!-- README.md is generated from README.qmd. Please edit that file -->\n\n\n\n\n\n# Setup instructions for using GUDHI from R\n\n<!-- badges: start -->\n\n<!-- badges: end -->\n\n## The [**reticulate**](https://rstudio.github.io/reticulate/) package\n\nThe [**reticulate**](https://rstudio.github.io/reticulate/) package\nprovides a comprehensive set of tools for interoperability between\nPython and R. The package includes facilities for:\n\n- Calling Python from R in a variety of ways including R Markdown,\n sourcing Python scripts, importing Python modules, and using Python\n interactively within an R session.\n- Translation between R and Python objects (for example, between R and\n Pandas data frames, or between R matrices and NumPy arrays).\n- Flexible binding to different versions of Python including virtual\n environments and Conda environments.\n\n[**reticulate**](https://rstudio.github.io/reticulate/) embeds a Python\nsession within your R session, enabling seamless, high-performance\ninteroperability. If you are an R developer that uses Python for some of\nyour work or a member of data science team that uses both languages,\n[**reticulate**](https://rstudio.github.io/reticulate/) can dramatically\nstreamline your workflow.\n\n## Bring GUDHI into R\n\n- First, you'll want to install and load the\n [**reticulate**](https://rstudio.github.io/reticulate/) package into\n your session:\n\n\n ::: {.cell}\n \n ```{.r .cell-code}\n # install.packages(\"reticulate\")\n library(reticulate)\n ```\n :::\n\n\n- Next, the fastest way to get you set up to use Python from R with\n [**reticulate**](https://rstudio.github.io/reticulate/) is to use\n the `install_miniconda()` utility function which is included in the\n [**reticulate**](https://rstudio.github.io/reticulate/) package. In\n details, use something like:\n\n\n ::: {.cell}\n \n ```{.r .cell-code}\n install_miniconda()\n ```\n :::\n\n\n- Next, it is recommended that you create a virtual conda environment\n in which you'll install all required Python packages. This can be\n achieved using the `reticulate::conda_create()` function as follows:\n\n\n ::: {.cell}\n \n ```{.r .cell-code}\n version <- \"3.9.6\"\n conda_create(\"r-reticulate\", python_version = version)\n ```\n :::\n\n\n- Next, you can seamlessly install all the Python packages you need by\n calling the `conda_install()` function. For instance, to use Gudhi,\n you would do something like:\n\n\n ::: {.cell}\n \n ```{.r .cell-code}\n conda_install(\"scikit-learn\", envname = \"r-reticulate\")\n conda_install(\"gudhi\", envname = \"r-reticulate\")\n ```\n :::\n\n\nThis is a setup that you ought to do only once (unless you want to\nchange your Python version for some reason).\n\nIf you want to check your Python configuration, you can do:\n\n\n::: {.cell}\n\n```{.r .cell-code}\npy_config()\n#> python: /Users/stamm-a/Library/r-miniconda/envs/r-reticulate/bin/python3.9\n#> libpython: /Users/stamm-a/Library/r-miniconda/envs/r-reticulate/lib/libpython3.9.dylib\n#> pythonhome: /Users/stamm-a/Library/r-miniconda/envs/r-reticulate:/Users/stamm-a/Library/r-miniconda/envs/r-reticulate\n#> version: 3.9.6 | packaged by conda-forge | (default, Jul 11 2021, 03:36:15) [Clang 11.1.0 ]\n#> numpy: /Users/stamm-a/Library/r-miniconda/envs/r-reticulate/lib/python3.9/site-packages/numpy\n#> numpy_version: 1.22.4\n#> \n#> NOTE: Python version was forced by RETICULATE_PYTHON\n```\n:::\n\n\n# Organisation\n\n## File hierarchy\n\nThis folder contains a number of [Quarto](https://quarto.org) documents\ncontributed with the purpose of showing how\n[`R`](https://www.r-project.org) can be used to enhance statistical\nanalysis of topological data produced via\n[Gudhi](https://gudhi.inria.fr). Each tutorial is hosted in its own\nfolder which is organised as follows:\n\n- The Quarto document with extension `.qmd` which is the main file\n that a developer is supposed to contribute. In this document, there\n is a YAML header in which the contributor can specify various output\n formats by adding\n\n ``` yaml\n #| eval: false\n format:\n html: default\n gfm: default\n pdf: default\n ```\n\n The complete list of possible output formats:\n <https://quarto.org/docs/output-formats/all-formats.html>.\n\n- A Github-flavored markdown (GMF) document with extension `.md` which\n enables nice visualization of the notebook directly in the Github\n web interface.\n\n- A folder containing useful libs and resources to display the GMF\n document.\n\n## Contributing\n\nIf you want to contribute, you should\n\n1. Fork the `TDA-tutorials` repo\n2. Open the RStudio project in\n `TDA-tutorials/r-interface/r-interface.Rproj`.\n3. When opened in RStudio, the working directory should now be\n `TDA-tutorials/r-interface/` in which you can now create a folder\n with evocative name to put the Quarto document describing the\n analysis you want to share.\n - Note: you can use the same YAML header as in\n `reticulate/reticulate.qmd` as a number of presets for rendering\n are made into the `_quarto.yml` file.\n", | ||
"supporting": [ | ||
"README_files" | ||
], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": {}, | ||
"postProcess": true | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should add
_freeze
directory in.gitignore
, and also remove it from the git repository.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should add
reticulate/reticulate_files/libs
directory in.gitignore
, and also remove it from the git repository.