|
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/" |
|
|
|
|
|
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(filepath) |
|
for i, row in df.iterrows(): |
|
target = row["target"] |
|
values = row.drop("target").values |
|
yield i, { |
|
"values": values, |
|
"target": target, |
|
} |