File size: 2,774 Bytes
803d2ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import datasets
import pandas as pd

_CITATION = """\
Feng Q, Liang S, Jia H, et al. Gut microbiome development along the colorectal adenoma-carcinoma sequence. Nat Commun. 2015;6:6528. Published 2015 Mar 11. doi:10.1038/ncomms7528
"""

_DESCRIPTION = """\
The dataset contains 16S rRNA gene sequencing data from healthy controls and colorectal cancer patients. The dataset was used in the paper "Gut microbiome development along the colorectal adenoma-carcinoma sequence" by Feng et al. (2015).
"""

_HOMEPAGE = "https://pubmed.ncbi.nlm.nih.gov/25758642/"

_URL = "https://huggingface.co/datasets/wwydmanski/colorectal-carcinoma-microbiome-fengq/raw/main/"

class ColorectalCarcinomaMicrobiomeFengQConfig(datasets.GeneratorBasedBuilder):
    BUILDER_CONFIGS = [
        datasets.BuilderConfig(
            name="presence-absence",
            description="Binary presence/absence of taxa",
        ),
        datasets.BuilderConfig(
            name="CLR",
            description="Relative abundance of taxa",
        ),
    ]

    DEFAULT_CONFIG_NAME = "presence-absence"

    def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            citation=_CITATION,
            homepage=_HOMEPAGE,
            version=datasets.Version("0.1.0"),
        )
    
    def _split_generators(self, dl_manager):
        if self.config.name == "presence-absence":
            return [
                datasets.SplitGenerator(
                    name=datasets.Split.TRAIN,
                    gen_kwargs={
                        "filepath": "PA_train.csv",
                        "split": "train",
                    },
                ),
                datasets.SplitGenerator(
                    name=datasets.Split.TEST,
                    gen_kwargs={
                        "filepath": "PA_test.csv",
                        "split": "test",
                    },
                ),
            ]
        elif self.config.name == "CLR":
            return [
                datasets.SplitGenerator(
                    name=datasets.Split.TRAIN,
                    gen_kwargs={
                        "filepath": "CLR_train.csv",
                    },
                ),
                datasets.SplitGenerator(
                    name=datasets.Split.TEST,
                    gen_kwargs={
                        "filepath": "CLR_test.csv",
                    },
                ),
            ]
        
    def _generate_examples(self, filepath, split=None):
        df = pd.read_csv(_URL+filepath)
        for i, row in df.iterrows():
            target = row["target"]
            values = row.drop("target").values
            yield i, { 
                "values": values,
                "target": target,
            }