luxai commited on
Commit
25eca30
1 Parent(s): 74a00e4

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -56,3 +56,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
56
  # Video files - compressed
57
  *.mp4 filter=lfs diff=lfs merge=lfs -text
58
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
56
  # Video files - compressed
57
  *.mp4 filter=lfs diff=lfs merge=lfs -text
58
  *.webm filter=lfs diff=lfs merge=lfs -text
59
+ data/17_04_24_YolkSacRaw_F158_WE_annots.h5ad filter=lfs diff=lfs merge=lfs -text
data/17_04_24_YolkSacRaw_F158_WE_annots.h5ad ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b97cd1a83ed6ac94d40ce86f41c8d6298af9134768133eaa71f72ff548d85ba
3
+ size 552929816
yolksac_human.py ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # Lint as: python3
17
+ """The RNA Expression Baseclass."""
18
+
19
+
20
+ import json
21
+ import os
22
+ import anndata as ad
23
+ import pyarrow as pa
24
+ import pandas as pd
25
+
26
+ import datasets
27
+ CITATION = """
28
+ Test
29
+ """
30
+
31
+ DESCRIPTION = """
32
+ Test
33
+ """
34
+
35
+ class RNAExpConfig(datasets.BuilderConfig):
36
+ """BuilderConfig for RNAExpConfig."""
37
+
38
+ def __init__(self, features, data_url, citation, url, raw_counts="X", **kwargs):
39
+ """BuilderConfig for RNAExpConfig.
40
+ Args:
41
+ features: `list[string]`, list of the features that will appear in the
42
+ feature dict. Should not include "label".
43
+ data_url: `string`, url to download the zip file from.
44
+ citation: `string`, citation for the data set.
45
+ url: `string`, url for information about the data set.
46
+
47
+ **kwargs: keyword arguments forwarded to super.
48
+ """
49
+ # Version history:
50
+ # 0.0.1: Initial version.
51
+ super(RNAExpConfig, self).__init__(version=datasets.Version("0.0.1"), **kwargs)
52
+ self.features = features
53
+ self.data_url = data_url
54
+ self.citation = citation
55
+ self.url = url
56
+ self.raw_counts = raw_counts # Could be raw.X
57
+ self.batch = 1000
58
+
59
+
60
+
61
+
62
+ # class RNAExp(datasets.GeneratorBasedBuilder):
63
+ class RNAExp(datasets.ArrowBasedBuilder):
64
+ """RNA Expression Baseclass."""
65
+
66
+ def _info(self):
67
+ self.config = RNAExpConfig(
68
+ name="human_yolk_sac",
69
+ description = DESCRIPTION,
70
+ features=["raw_counts","LVL1"],
71
+ raw_counts = "X",
72
+ data_url="./data/17_04_24_YolkSacRaw_F158_WE_annots.h5ad",
73
+ citation=CITATION,
74
+ url="https://www.ebi.ac.uk/biostudies/arrayexpress/studies/E-MTAB-11673")
75
+
76
+ features = {"raw_counts": datasets.features.Sequence(feature=datasets.Value("int32"))}
77
+ # features = {gene: datasets.Value("int32") for gene in adata.var.index.str.lower().tolist()}
78
+ for feature in self.config.features:
79
+ if features.get(feature,None) is None:
80
+ features[feature] = datasets.Value("string")
81
+
82
+
83
+
84
+ return datasets.DatasetInfo(
85
+ description= self.config.description,
86
+ features=datasets.Features(features),
87
+ homepage=self.config.url,
88
+ citation=self.config.citation,
89
+ )
90
+
91
+ def _split_generators(self, dl_manager):
92
+ # self.gene_names_file = dl_manager.download_and_extract(
93
+ # "data/gene_names.csv"
94
+ # )
95
+ self.anndata_file = dl_manager.download_and_extract(self.config.data_url)
96
+
97
+ return [
98
+ datasets.SplitGenerator(
99
+ name=datasets.Split.TRAIN,
100
+ gen_kwargs={"split": "train","expression_file": self.anndata_file,"batch_size":self.config.batch},#,"gene_names_file": self.gene_names_file},
101
+ )
102
+ ]
103
+
104
+ def _generate_examples(self, expression_file, split):
105
+
106
+ # genes = pd.read_csv(gene_names_file)
107
+ adata = ad.read_h5ad(expression_file)
108
+ if self.config.raw_counts =="X":
109
+ X = adata.X
110
+ else:
111
+ X = adata.var[raw_counts]
112
+ num_cells = X.shape[0]
113
+ for _id,cell in enumerate(X):
114
+ example = {"raw_counts": cell.toarray().flatten()}
115
+
116
+ for feature in self.config.features:
117
+ if example.get(feature,None) is None:
118
+ example[feature] = adata.obs[feature][_id]
119
+
120
+ yield _id,example
121
+
122
+ def _generate_tables(self, expression_file,batch_size,split):
123
+ idx = 0
124
+ adata = ad.read_h5ad(expression_file)
125
+ for batch in range(0,adata.shape[0],batch_size):
126
+ chunk = adata.X[batch:batch+batch_size].todense().astype('int32')
127
+ df = pd.DataFrame(chunk,columns=adata.var.index.str.lower())
128
+ df["raw_counts"] = [x for x in df.to_numpy()]
129
+ df = df[["raw_counts"]]
130
+ for feature in self.config.features:
131
+ if feature != "raw_counts":
132
+ df[feature] = adata.obs[feature][batch:batch+batch_size].tolist()
133
+ print(df.shape)
134
+ pa_table = pa.Table.from_pandas(df)
135
+ yield idx, pa_table
136
+ idx += 1