luxai commited on
Commit
38cb367
·
verified ·
1 Parent(s): a024f23

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. yolksac_human.py +10 -13
yolksac_human.py CHANGED
@@ -74,11 +74,10 @@ 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
  # 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,7 +86,7 @@ class RNAExp(datasets.ArrowBasedBuilder):
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
  )
@@ -132,12 +131,13 @@ class RNAExp(datasets.ArrowBasedBuilder):
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
 
@@ -145,11 +145,8 @@ class RNAExp(datasets.ArrowBasedBuilder):
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
 
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
  for feature in self.config.features:
82
  if features.get(feature,None) is None:
83
  features[feature] = datasets.Value("string")
 
86
 
87
  return datasets.DatasetInfo(
88
  description= self.config.description,
89
+ features=None, #datasets.Features(features),
90
  homepage=self.config.url,
91
  citation=self.config.citation,
92
  )
 
131
  adata = ad.read_h5ad(expression_file)
132
  genes = adata.var_names.str.lower().to_list()
133
 
134
+ features = {"raw_counts": datasets.features.Sequence(datasets.features.Value("int32"),id = ",".join(adata.var.index.str.lower().tolist()))}
135
+ for feature in self.config.features:
136
+ if features.get(feature,None) is None:
137
+ features[feature] = datasets.Value("string")
138
+
139
+ self.info.features = datasets.Features(features)
140
 
 
141
 
142
  # self.info.features['gene_names'] = datasets.features.ClassLabel(names = genes)
143
 
 
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 = df[["raw_counts"]]
 
 
 
150
  ## 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
151
  ## Another option would be to replace the description with the list of genes
152
  # df[",".join(adata.var.index.str.lower().tolist())] = True