-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #466 from pepkit/443_add_classmethod
Updated initiation object method with class methods
- Loading branch information
Showing
10 changed files
with
237 additions
and
39 deletions.
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
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,75 @@ | ||
# 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. | ||
|
||
## 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) | ||
```python | ||
import peppy | ||
project = peppy.Project.from_pep_config("path/to/project/sample_sheet.csv") | ||
``` | ||
|
||
## 3. Using yaml sample sheet | ||
|
||
```python | ||
import peppy | ||
|
||
project = peppy.Project.from_sample_yaml("path/to/project/sample_sheet.yaml") | ||
``` | ||
|
||
|
||
## 4. Using 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 | ||
```python | ||
import peppy | ||
project = peppy.Project.from_dict( | ||
{'_config': {'description': None, | ||
'name': 'example_basic', | ||
'pep_version': '2.0.0', | ||
'sample_table': 'sample_table.csv',}, | ||
'_sample_dict': [{'organism': 'pig', 'sample_name': 'pig_0h', 'time': '0'}, | ||
{'organism': 'pig', 'sample_name': 'pig_1h', 'time': '1'}, | ||
{'organism': 'frog', 'sample_name': 'frog_0h', 'time': '0'}, | ||
{'organism': 'frog', 'sample_name': 'frog_1h', 'time': '1'}], | ||
'_subsample_list': [[{'read1': 'frog1a_data.txt', | ||
'read2': 'frog1a_data2.txt', | ||
'sample_name': 'frog_0h'}, | ||
{'read1': 'frog1b_data.txt', | ||
'read2': 'frog1b_data2.txt', | ||
'sample_name': 'pig_0h'}, | ||
{'read1': 'frog1c_data.txt', | ||
'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") | ||
``` |
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
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 +1 @@ | ||
__version__ = "0.40.0a5" | ||
__version__ = "0.40.0a6" |
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
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
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 |
---|---|---|
|
@@ -3,4 +3,3 @@ pyyaml | |
rich>=10.3.0 | ||
ubiquerg>=0.6.2 | ||
numpy | ||
yacman>=0.9.0 |
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
6 changes: 6 additions & 0 deletions
6
tests/data/example_peps-master/example_basic_sample_yaml/sample.yaml
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,6 @@ | ||
- sample_name: sample1 | ||
file: path/to/file.tsv | ||
- sample_name: sample2 | ||
file: path/to/2.tsv | ||
- sample_name: sample3 | ||
file: path/to/3.tsv |
Oops, something went wrong.