MCPcopy Create free account
hub / github.com/CamaraLab/scTDA / __init__

Method __init__

scTDA/main.py:277–356  ·  view source on GitHub ↗

Initializes the class by providing a list of files ('files'), timepoints ('timepoints') and library id's ('libs'), as well as the number of cells per file ('cells'), which can be a list, and the common identifier for the RNA spike-in reads ('spike'). The order of the genes m

(self, files, timepoints, libs, cells, spike='_null_')

Source from the content-addressed store, hash-verified

275 points. It permits to read, filter and organize the data to put it in the appropriate form for SCTDA.
276 """
277 def __init__(self, files, timepoints, libs, cells, spike='_null_'):
278 """
279 Initializes the class by providing a list of files ('files'), timepoints ('timepoints') and library id's
280 ('libs'), as well as the number of cells per file ('cells'), which can be a list, and the common identifier
281 for the RNA spike-in reads ('spike'). The order of the genes must be the same in all files.
282 """
283 self.sigmoid = False
284 self.cdr = []
285 self.residuals = {}
286 self.subsampled = False
287 self.target_subsample = 0.0
288 self.data = []
289 self.spike = spike
290 if type(cells) != list:
291 self.len = [cells]*len(files)
292 else:
293 self.len = cells
294 self.fil = files
295 self.long = list(numpy.repeat(timepoints, self.len))
296 self.batch = list(numpy.repeat(libs, self.len))
297 self.cal = []
298 self.cal2 = []
299 self.tal = {}
300 totalspikes = {}
301 self.totaltransc = {}
302 self.spikes_ratio = {}
303 self.data_spikes = []
304 datat = {}
305 qft = {}
306 self.genes = []
307 self.totaltran = []
308 for nn, f in enumerate(self.fil):
309 carma = []
310 totalspikes[f] = numpy.zeros(self.len[nn])
311 self.totaltransc[f] = numpy.zeros(self.len[nn])
312 self.spikes_ratio[f] = numpy.zeros(self.len[nn])
313 datat[f] = []
314 qft[f] = []
315 fol = open(f, 'r')
316 qty = 0
317 for line in fol:
318 sp = line[:-1].split('\t')
319 q = numpy.array(map(lambda x: float(x), sp[1:]))
320 if spike in sp[0]:
321 qft[f].append(q)
322 totalspikes[f] += q
323 if numpy.mean(q) > 0.0:
324 carma.append(q/numpy.mean(q))
325 qty += 1
326 else:
327 self.totaltransc[f] += q
328 datat[f].append(q)
329 if nn == 0:
330 self.genes.append(sp[0])
331 if spike != '_null_':
332 self.spikes_ratio[f] = totalspikes[f]/self.totaltransc[f]
333 self.cal2 += list(self.spikes_ratio[f])
334 fol.close()

Callers 1

__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected