Upload folder using huggingface_hub
Browse files- data/meta_data.csv +0 -0
- yolksac_human.py +32 -9
data/meta_data.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
yolksac_human.py
CHANGED
@@ -74,8 +74,11 @@ class RNAExp(datasets.ArrowBasedBuilder):
|
|
74 |
citation=CITATION,
|
75 |
url="https://www.ebi.ac.uk/biostudies/arrayexpress/studies/E-MTAB-11673")
|
76 |
|
77 |
-
features = {"raw_counts": datasets.features.Sequence(feature=datasets.Value("int32"))}
|
78 |
-
|
|
|
|
|
|
|
79 |
for feature in self.config.features:
|
80 |
if features.get(feature,None) is None:
|
81 |
features[feature] = datasets.Value("string")
|
@@ -84,16 +87,17 @@ class RNAExp(datasets.ArrowBasedBuilder):
|
|
84 |
|
85 |
return datasets.DatasetInfo(
|
86 |
description= self.config.description,
|
87 |
-
features=None
|
88 |
homepage=self.config.url,
|
89 |
citation=self.config.citation,
|
90 |
)
|
91 |
|
92 |
def _split_generators(self, dl_manager):
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
self.anndata_file = dl_manager.download_and_extract(self.config.data_url)
|
|
|
97 |
|
98 |
return [
|
99 |
datasets.SplitGenerator(
|
@@ -107,6 +111,8 @@ class RNAExp(datasets.ArrowBasedBuilder):
|
|
107 |
# genes = pd.read_csv(gene_names_file)
|
108 |
adata = ad.read_h5ad(expression_file)
|
109 |
self.genes_list = adata.var.index.str.lower().tolist()
|
|
|
|
|
110 |
if self.config.raw_counts =="X":
|
111 |
X = adata.X
|
112 |
else:
|
@@ -124,20 +130,37 @@ class RNAExp(datasets.ArrowBasedBuilder):
|
|
124 |
def _generate_tables(self, expression_file,batch_size,split):
|
125 |
idx = 0
|
126 |
adata = ad.read_h5ad(expression_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
# self.info.description = adata.var.index.str.lower().tolist() #"+".join(adata.var.index.str.lower().tolist())
|
128 |
for batch in range(0,adata.shape[0],batch_size):
|
129 |
chunk = adata.X[batch:batch+batch_size].todense().astype('int32')
|
130 |
df = pd.DataFrame(chunk,columns=adata.var.index.str.lower())
|
131 |
-
df["raw_counts"] = [x for x in df.to_numpy()]
|
132 |
-
df
|
|
|
|
|
|
|
133 |
## We create a dummy column with all the names of the genes as list. We don't use this as value since this would unnecessarily increase the size of the dataset
|
134 |
## Another option would be to replace the description with the list of genes
|
135 |
-
df[",".join(adata.var.index.str.lower().tolist())] = True
|
|
|
|
|
136 |
for feature in self.config.features:
|
137 |
if feature != "raw_counts":
|
138 |
df[feature] = adata.obs[feature][batch:batch+batch_size].tolist()
|
139 |
|
140 |
# df['gene_names'] = [adata.var.index.str.lower().tolist()]*batch_size
|
|
|
141 |
pa_table = pa.Table.from_pandas(df)
|
142 |
yield idx, pa_table
|
143 |
idx += 1
|
|
|
74 |
citation=CITATION,
|
75 |
url="https://www.ebi.ac.uk/biostudies/arrayexpress/studies/E-MTAB-11673")
|
76 |
|
77 |
+
# features = {"raw_counts": datasets.features.Sequence(feature=datasets.Value("int32"))}
|
78 |
+
|
79 |
+
# features = {"raw_counts": datasets.features.Sequence(feature={"gene":datasets.Value("string"),"count":datasets.Value("int32")})}
|
80 |
+
# features = {"raw_counts": datasets.Value("int32") for gene in adata.var.index.str.lower().tolist()}
|
81 |
+
features = {}
|
82 |
for feature in self.config.features:
|
83 |
if features.get(feature,None) is None:
|
84 |
features[feature] = datasets.Value("string")
|
|
|
87 |
|
88 |
return datasets.DatasetInfo(
|
89 |
description= self.config.description,
|
90 |
+
features=None,#,datasets.Features(features),
|
91 |
homepage=self.config.url,
|
92 |
citation=self.config.citation,
|
93 |
)
|
94 |
|
95 |
def _split_generators(self, dl_manager):
|
96 |
+
self.gene_names_file = dl_manager.download_and_extract(
|
97 |
+
"./data/meta_data.csv"
|
98 |
+
)
|
99 |
self.anndata_file = dl_manager.download_and_extract(self.config.data_url)
|
100 |
+
|
101 |
|
102 |
return [
|
103 |
datasets.SplitGenerator(
|
|
|
111 |
# genes = pd.read_csv(gene_names_file)
|
112 |
adata = ad.read_h5ad(expression_file)
|
113 |
self.genes_list = adata.var.index.str.lower().tolist()
|
114 |
+
|
115 |
+
|
116 |
if self.config.raw_counts =="X":
|
117 |
X = adata.X
|
118 |
else:
|
|
|
130 |
def _generate_tables(self, expression_file,batch_size,split):
|
131 |
idx = 0
|
132 |
adata = ad.read_h5ad(expression_file)
|
133 |
+
genes = adata.var_names.str.lower().to_list()
|
134 |
+
|
135 |
+
# features = {"raw_counts": datasets.features.Sequence(datasets.features.ClassLabel(names = genes))}
|
136 |
+
# for feature in self.config.features:
|
137 |
+
# if features.get(feature,None) is None:
|
138 |
+
# features[feature] = datasets.Value("string")
|
139 |
+
|
140 |
+
# self.info.features = datasets.features.Features(features)
|
141 |
+
|
142 |
+
# self.info.features['gene_names'] = datasets.features.ClassLabel(names = genes)
|
143 |
+
|
144 |
# self.info.description = adata.var.index.str.lower().tolist() #"+".join(adata.var.index.str.lower().tolist())
|
145 |
for batch in range(0,adata.shape[0],batch_size):
|
146 |
chunk = adata.X[batch:batch+batch_size].todense().astype('int32')
|
147 |
df = pd.DataFrame(chunk,columns=adata.var.index.str.lower())
|
148 |
+
# df["raw_counts"] = [x for x in df.to_numpy()]
|
149 |
+
# df.apply(lambda x: [(x,y) for x,y in zip(genes, x)],axis=1)
|
150 |
+
|
151 |
+
# [x for x in df.to_numpy()]
|
152 |
+
# df = df[["raw_counts"]]
|
153 |
## We create a dummy column with all the names of the genes as list. We don't use this as value since this would unnecessarily increase the size of the dataset
|
154 |
## Another option would be to replace the description with the list of genes
|
155 |
+
# df[",".join(adata.var.index.str.lower().tolist())] = True
|
156 |
+
# df['gene_names'] = True
|
157 |
+
|
158 |
for feature in self.config.features:
|
159 |
if feature != "raw_counts":
|
160 |
df[feature] = adata.obs[feature][batch:batch+batch_size].tolist()
|
161 |
|
162 |
# df['gene_names'] = [adata.var.index.str.lower().tolist()]*batch_size
|
163 |
+
# print(df)
|
164 |
pa_table = pa.Table.from_pandas(df)
|
165 |
yield idx, pa_table
|
166 |
idx += 1
|