Skip to content

Commit

Permalink
Merge pull request #908 from josschavezf/suite
Browse files Browse the repository at this point in the history
update website
  • Loading branch information
josschavezf authored Feb 12, 2024
2 parents e161d27 + 5f3bc4c commit 27a762b
Show file tree
Hide file tree
Showing 36 changed files with 727 additions and 568 deletions.
17 changes: 12 additions & 5 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ navbar:
href: articles/ecosystem.html
- text: Giotto Class Structure
href: articles/structure.html
- text: Solutions to Installation Errors
href: articles/errorsfaqsandtips.html
- text: FAQs
href: articles/faqs.html
- text: How to report a bug
- text: How to report a bug
href: articles/github_issues.html
- text: Contributing guide
href: articles/contributing.html
reference:
text: Documentation
href: reference/index.html
Expand Down Expand Up @@ -194,26 +194,33 @@ navbar:
href: articles/presentations.html
- text: Branches
href: articles/branches.html
team:
- text: Team
href: articles/team.html
github:
icon: fab fa-github fa-lg
href: https://github.com/drieslab/Giotto/
aria-label: github

articles:
- title: Team
navbar: ~
contents:
- team
- title: News
navbar: ~
contents:
- presentations
- branches
- title: Get started
navbar: ~
contents:
- installation
- ecosystem
- structure
- errorsfaqsandtips
- faqs
- branches
- github_issues
- contributing
- title: Giotto Object Creation
navbar: ~
contents:
Expand Down
15 changes: 6 additions & 9 deletions vignettes/codex_mouse_spleen.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@ vignette: >
```{r, eval=FALSE}
# Ensure Giotto Suite is installed.
if(!"Giotto" %in% installed.packages()) {
devtools::install_github("drieslab/Giotto@suite")
pak::pkg_install("drieslab/Giotto")
}
# Ensure GiottoData, a small, helper module for tutorials, is installed.
if(!"GiottoData" %in% installed.packages()) {
devtools::install_github("drieslab/GiottoData")
pak::pkg_install("drieslab/GiottoData")
}
library(Giotto)
# Ensure the Python environment for Giotto has been installed.
genv_exists = checkGiottoEnvironment()
genv_exists = Giotto::checkGiottoEnvironment()
if(!genv_exists){
# The following command need only be run once to install the Giotto environment.
installGiottoEnvironment()
Giotto::installGiottoEnvironment()
}
```

Expand All @@ -48,11 +47,9 @@ my_python_path = NULL # alternatively, "/local/python/path/python" if desired.

# Dataset explanation

The CODEX data to run this tutorial can be found [here](https://github.com/drieslab/spatial-datasets/tree/master/data/2018_codex_spleen). Alternatively you can use the **getSpatialDataset** to automatically
download this dataset like we do in this example.
The CODEX data to run this tutorial can be found [here](https://github.com/drieslab/spatial-datasets/tree/master/data/2018_codex_spleen). Alternatively you can use the **getSpatialDataset** to automatically download this dataset like we do in this example.

[Goltsev et al.](https://www.cell.com/cell/pdf/S0092-8674(18)30904-8.pdf) created a multiplexed datasets of normal and lupus (MRL/lpr) murine spleens using CODEX technique. The dataset consists of 30 protein markers from 734,101
single cells. In this tutorial, 83,787 cells from sample "BALBc-3" were
[Goltsev et al.](https://www.cell.com/cell/pdf/S0092-8674(18)30904-8.pdf) created a multiplexed datasets of normal and lupus (MRL/lpr) murine spleens using CODEX technique. The dataset consists of 30 protein markers from 734,101 single cells. In this tutorial, 83,787 cells from sample "BALBc-3" were
selected for the analysis.


Expand Down
20 changes: 2 additions & 18 deletions vignettes/configuration.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,19 @@ Giotto contains several functions that contain wrappers to Python code and thus
```{r, eval=FALSE}
# Ensure Giotto Suite is installed
if(!"Giotto" %in% installed.packages()) {
devtools::install_github("drieslab/Giotto")
pak::pkg_install("drieslab/Giotto")
}
library(Giotto)
# Ensure Giotto Data is installed
if(!"GiottoData" %in% installed.packages()) {
devtools::install_github("drieslab/GiottoData")
pak::pkg_install("drieslab/GiottoData")
}
library(GiottoData)
```

NOTE: With the most recent version of Giotto, the following error has been observed, particularly when installing the package from a terminal:

![](images/installation/timeout.png)


This error is related to the time required for downloading the package. To solve the error, increase the limit of downloading time by running this code in your R console:

```{r, eval=FALSE}
options(timeout = max(1000, getOption("timeout")))
```

If you are doing the installation through a linux terminal, you can run instead this command to directly modify your R environment variable:

```
echo "R_DEFAULT_INTERNET_TIMEOUT = 1000" >> .Renviron
```

```{r, eval=FALSE}
Expand Down
155 changes: 155 additions & 0 deletions vignettes/contributing.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
---
title: "How to Contribute?"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{How to Contribute?}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

We welcome contributions or suggestions from other developers. Please contact us if you have questions or would like to discuss an addition or major modifications to the Giotto main code.
The source code for Giotto Suite may be found on our [GitHub repository](https://github.com/drieslab/Giotto/).


# Coding Style

Following a particular programming style will help programmers read and understand source code conforming to the style, and help to avoid introducing errors. Here we present a small list of guidelines on what is considered a good practice when writing R codes in Giotto package. Most of them are adapted from [Bioconductor - coding style](https://bioconductor.org/developers/how-to/coding-style/) or [Google's R Style Guide](https://google.github.io/styleguide/Rguide.xml). These guidelines are preferences and strongly encouraged!

- **Naming**
- Use camelCase for Giotto user-facing exported function names. (`functionName()`)
- Use snake_case for non-user-facing exported functions, which are essentially any functions not directly related to commonly used data processing, analysis, and visualization. (`function_name()`)
- Use "." prefix and snake_case for internal non-exported functions. (`.function_name()`)
- Use snake_case for parameter names.
- Do not use "." as a separator in function naming. (in the S3 class system, some(x) where x is class A will dispatch to some.A)

- **Use of space**
- Do not place a space before a comma, but always place one after a comma. This: `a, b, c`.
- Always use space around “=” when using named arguments to functions. This: `somefunc(a = 1, b = 2)`.

- **Use of symbols**
- Do not use any non-UTF-8 characters unless provided as the escape code. For example: `'\u00F6'` for `ö`

Beyond these guidelines, [*styler*](https://github.com/r-lib/styler) should be used in order to maintain code uniformity.


# Stat functions

Most Giotto commands can accept several matrix classes (DelayedMatrix, SparseM, Matrix or base matrix). To
facilitate this we provide **flexible** wrappers that work on any type of matrix class.

- **mean_flex**: analogous to mean()
- **rowSums_flex**: analogous to rowSums()
- **rowMeans_flex**: analogous to rowMeans()
- **colSums_flex**: analogous to colSums()
- **colMeans_flex**: analogous to colMeans()
- **t_flex**: analogous to t()
- **cor_flex**: analogous to cor()



# Auxiliary functions

Giotto has a number of auxiliary or convenience functions that might help you to adapt your code or write new code for Giotto. We encourage you to use these small functions to maintain uniformity throughout the code.

- **lapply_flex**: analogous to lapply() and works for both windows and unix systems
- **all_plots_save_function**: compatible with Giotto instructions and helps to automatically save generated plots
- **plot_output_handler**: further wraps `all_plots_save_function` and includes handling for return_plot and show_plot and Giotto instructions checking
- **determine_cores**: to determine the number of cores to use if a user does not set this explicitly
- **get_os**: to identify the operating system
- **update_giotto_params**: will catch and store the parameters for each used command on a giotto object
- **wrap_txt** and **wrap_msg**: text and message formatting functions
- **vmsg**: framework for Giotto's verbosity-flagged messages
- **package_check**: to check if a package exists, works for packages on CRAN, Bioconductor and Github

The last function should be used within your contribution code. It has the additional benefit that it will suggest the user how to download the package if it is not available. To keep the size of Giotto within limits we prefer not to add too many new dependencies.


# Package Imports

Giotto tracks packages and functions to import in a centralized manner. When adding code that requires functions from another package, add the roxygen tags to the `package_imports.R` file for that Giotto module.


# Getters and Setters

Giotto stores information in different [slots](articles/structure.html#giotto-object-structure), which can be accessed through these getters and setters functions. They can be found in the [accessors.R](https://github.com/drieslab/Giotto/blob/suite/R/accessors.R) file.

- **getCellMetadata()**: Gets cell metadata
- **setCellMetadata()**: Sets cell metadata

- **getFeatureMetadata()**: Gets feature metadata
- **getFeatureMetadata()**: Sets feature metadata

- **getExpression()**: To select the expression matrix to use
- **setExpression()**: Sets a new expression matrix to the expression slot

- **getSpatialLocations()**: Get spatial locations to use
- **setSpatialLocations()**: Sets new spatial locations

- **getDimReduction()**: To select the dimension reduction values to use
- **setDimReduction()**: Sets new dimension reduction object

- **getNearestNetwork()**: To select the nearest neighbor network (kNN or sNN) to use
- **setNearestNetwork()**: Sets a new nearest neighbor network (kNN or sNN)

- **getSpatialNetwork()**: To select the spatial network to use
- **setSpatialNetwork()**: Sets a new spatial network

- **getPolygonInfo()**: Gets spatial polygon information
- **setPolygonInfo()**: Set new spatial polygon information

- **getFeatureInfo()**: Gets spatial feature information
- **setFeatureInfo()**: Sets new spatial feature information

- **getSpatialEnrichment()**: Gets spatial enrichment information
- **setSpatialEnrichment()**: Sets new spatial enrichment information

- **getMultiomics()**: Gets multiomics information
- **setMultiomics()**: Sets multiomics information


# Python code

To use Python code we prefer to create a python wrapper/functions around the python code, which can then be sourced by reticulate. As an example we show the basic principles of how we implemented the Leiden clustering algorithm.

1. write python wrapper and store as python_leiden.py in */inst/python*:

```
import igraph as ig
import leidenalg as la
import pandas as pd
import networkx as nx
def python_leiden(df, partition_type, initial_membership=None, weights=None, n_iterations=2, seed=None, resolution_parameter = 1):
# create networkx object
Gx = nx.from_pandas_edgelist(df = df, source = 'from', target = 'to', edge_attr = 'weight')
# get weight attribute
myweights = nx.get_edge_attributes(Gx, 'weight')
....
return(leiden_dfr)
```


2. source python code with reticulate:

```
python_leiden_function = system.file("python", "python_leiden.py", package = 'Giotto')
reticulate::source_python(file = python_leiden_function)
```

3. use python code as if R code:
See **doLeidenCLuster** for more detailed information.

```
pyth_leid_result = python_leiden(df = network_edge_dt,
partition_type = partition_type,
initial_membership = init_membership,
weights = 'weight',
n_iterations = n_iterations,
seed = seed_number,
resolution_parameter = resolution)
```

12 changes: 6 additions & 6 deletions vignettes/ecosystem.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Find more information [here](https://drieslab.github.io/GiottoClass/)
To install GiottoClass run:

```{r, eval=FALSE}
devtools::install_github('drieslab/GiottoClass')
pak::pkg_install('drieslab/GiottoClass')
```

# 3. GiottoUtils
Expand All @@ -41,7 +41,7 @@ Find more information [here](https://drieslab.github.io/GiottoUtils/)
To install GiottoUtils run:

```{r, eval=FALSE}
devtools::install_github('drieslab/GiottoUtils')
pak::pkg_install('drieslab/GiottoUtils')
```

# 4. GiottoVisuals
Expand All @@ -53,7 +53,7 @@ Find more information [here](https://drieslab.github.io/GiottoVisuals/)
To install GiottoVisuals run:

```{r, eval=FALSE}
devtools::install_github('drieslab/GiottoVisuals')
pak::pkg_install('drieslab/GiottoVisuals')
```

# 5. GiottoData
Expand All @@ -67,7 +67,7 @@ Find more information [here](https://drieslab.github.io/GiottoData/)
To install GiottoData run:

```{r, eval=FALSE}
devtools::install_github('drieslab/GiottoData')
pak::pkg_install('drieslab/GiottoData')
```


Expand All @@ -79,14 +79,14 @@ The scripts used to create both the mini giotto objects and mini objects are ava
```{r, eval=FALSE}
# Ensure Giotto Suite is installed
if(!"Giotto" %in% installed.packages()) {
devtools::install_github("drieslab/Giotto")
pak::pkg_install("drieslab/Giotto")
}
library(Giotto)
# Ensure Giotto Data is installed
if(!"GiottoData" %in% installed.packages()) {
devtools::install_github("drieslab/GiottoData")
pak::pkg_install("drieslab/GiottoData")
}
library(GiottoData)
Expand Down
Loading

0 comments on commit 27a762b

Please sign in to comment.