Skip to content

Commit

Permalink
docs updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nsheff committed Dec 18, 2023
1 parent 8be815b commit d66f3cb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 29 deletions.
4 changes: 2 additions & 2 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
**This version introduced backwards-incompatible changes.**

### Changed
- Replaced attmap with MutableMapping. (which resulted in the removal of the attribute functionality previously available in attmap)
- Replaced attmap with MutableMapping (which removes some attribute)
- Replaced OrderedDict with dict.
- Deprecated support for Python versions <= 3.7.

_Due to the changes mentioned above, a few item functionalities may be disabled. For example, the `name` and `description` properties can now be accessed and modified using attribute functionality_

### Added
- Constructor methods: `from_dict`, `from_pandas`, `from_yaml`
- Constructor methods: `Project.from_dict`, `Project.from_pandas`, `Project.from_yaml`


## [0.35.7] -- 2023-07-19
Expand Down
61 changes: 35 additions & 26 deletions docs/initialize.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
# How to initiate peppy using different methods

peppy supports multiple ways to initiate a project. The most common way is to use a configuration file.
However, peppy also supports using a csv file (sample sheet), and a yaml file (sample sheet).
Additionally, peppy can be initiated using Python objects such as a pandas dataframe or a dictionary.
The primary use case of `peppy` is to create a `peppy.Project` object, which will give you an API for interacting with your project and sample metadata. There are multiple ways to instantiate a `peppy.Project`.
The most common is to use a configuration file; however, you can also use a `CSV` file (sample sheet), or a sample `YAML` file (sample sheet), or use Python objects directly, such as a `pandas` DataFrame, or a Python `dict`.

## 1. From PEP configuration file

## 1. Using a configuration file
```python
import peppy
project = peppy.Project.from_pep_config("path/to/project/config.yaml")
```

## 2. Using csv file (sample sheet)
## 2. FROM `CSV` file (sample sheet)

```python
import peppy
project = peppy.Project.from_pep_config("path/to/project/sample_sheet.csv")
```

## 3. Using yaml sample sheet
You can also instantiate directly from a URL to a CSV file:

```python
import peppy
project = peppy.Project("https://raw.githubusercontent.com/pepkit/example_peps/master/example_basic/sample_table.csv")
```


## 3. From `YAML` sample sheet

```python
import peppy
Expand All @@ -25,15 +34,33 @@ project = peppy.Project.from_sample_yaml("path/to/project/sample_sheet.yaml")
```


## 4. Using a pandas dataframe
## 4. From a `pandas` DataFrame

```python
import pandas as pd
import peppy
df = pd.read_csv("path/to/project/sample_sheet.csv")
project = peppy.Project.from_pandas(df)
```

## 5. Using a peppy generated dict
## 5. From a `peppy`-generated `dict`

Store a `peppy.Project` object as a dict using `prj.to_dict()`. Then, load it with `Project.from_dict()`:

```python
import peppy

project = peppy.Project("https://raw.githubusercontent.com/pepkit/example_peps/master/example_basic/sample_table.csv")
project_dict = project.to_dict(extended=True)
project_copy = peppy.Project.from_dict(project_dict)

# now you can check if this project is the same as the original project
print(project_copy == project)
```

Or, you could generate an equivalent dictionary in some other way:


```python
import peppy
project = peppy.Project.from_dict(
Expand All @@ -55,21 +82,3 @@ project = peppy.Project.from_dict(
'read2': 'frog1b_data2.txt',
'sample_name': 'pig_0h'}]]})
```

## 5.1 Generate dict from peppy and reuse it
```python
import peppy

project = peppy.Project("https://raw.githubusercontent.com/pepkit/example_peps/master/example_basic/sample_table.csv")
project_dict = project.to_dict(extended=True)
project_copy = peppy.Project.from_dict(project_dict)

# now you can check if this project is the same as the original project
print(project_copy == project)
```

## 6. Using a csv file from a url
```python
import peppy
project = peppy.Project("https://raw.githubusercontent.com/pepkit/example_peps/master/example_basic/sample_table.csv")
```
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ nav:
- Introduction: README.md
- Installing and Hello World: hello-world.md
- How-to Guides:
- How to initialize a Project: initialize.md
- How to use peppy: tutorial.md
- How to use subsample table: feature4_subsample_table.md
- How to use amendments: feature5_amend.md
- How to use append sample modifier: feature1_append.md
- How to use imply sample modifier: feature2_imply.md
- How to validate a PEP: validating.md
- How to initialize a peppy: initialize.md
- Reference:
- API: autodoc_build/peppy.md
- Support: support.md
Expand Down

0 comments on commit d66f3cb

Please sign in to comment.