Upload folder using huggingface_hub
Browse files- yolksac_human.py +7 -2
yolksac_human.py
CHANGED
@@ -22,6 +22,7 @@ import os
|
|
22 |
import anndata as ad
|
23 |
import pyarrow as pa
|
24 |
import pandas as pd
|
|
|
25 |
|
26 |
import datasets
|
27 |
CITATION = """
|
@@ -79,7 +80,7 @@ class RNAExp(datasets.ArrowBasedBuilder):
|
|
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,
|
@@ -105,6 +106,7 @@ class RNAExp(datasets.ArrowBasedBuilder):
|
|
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:
|
@@ -122,6 +124,8 @@ class RNAExp(datasets.ArrowBasedBuilder):
|
|
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())
|
@@ -130,7 +134,8 @@ class RNAExp(datasets.ArrowBasedBuilder):
|
|
130 |
for feature in self.config.features:
|
131 |
if feature != "raw_counts":
|
132 |
df[feature] = adata.obs[feature][batch:batch+batch_size].tolist()
|
133 |
-
|
|
|
134 |
pa_table = pa.Table.from_pandas(df)
|
135 |
yield idx, pa_table
|
136 |
idx += 1
|
|
|
22 |
import anndata as ad
|
23 |
import pyarrow as pa
|
24 |
import pandas as pd
|
25 |
+
import numpy as np
|
26 |
|
27 |
import datasets
|
28 |
CITATION = """
|
|
|
80 |
if features.get(feature,None) is None:
|
81 |
features[feature] = datasets.Value("string")
|
82 |
|
83 |
+
# features["gene_names"] = datasets.Sequence(datasets.Value("string"))
|
84 |
|
85 |
return datasets.DatasetInfo(
|
86 |
description= self.config.description,
|
|
|
106 |
|
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 |
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 |
+
self.column_names = adata.var.index.str.lower().tolist()
|
129 |
for batch in range(0,adata.shape[0],batch_size):
|
130 |
chunk = adata.X[batch:batch+batch_size].todense().astype('int32')
|
131 |
df = pd.DataFrame(chunk,columns=adata.var.index.str.lower())
|
|
|
134 |
for feature in self.config.features:
|
135 |
if feature != "raw_counts":
|
136 |
df[feature] = adata.obs[feature][batch:batch+batch_size].tolist()
|
137 |
+
|
138 |
+
# df['gene_names'] = [adata.var.index.str.lower().tolist()]*batch_size
|
139 |
pa_table = pa.Table.from_pandas(df)
|
140 |
yield idx, pa_table
|
141 |
idx += 1
|