def addLineToReturn(lineData): modLine = {} for c, x in zip(dfCols, lineData): if x == '': modLine[c] = None else: modLine[c] = x convData.addRow(DataRow.fromDict(modLine))
def dfSummary(cls, thisObservation, mc=10): df = DataFrame() madeObs = cls.summarizeKmers(thisObservation, mc) for idx, obs in enumerate(madeObs): if idx == 0: # header cols = [x for x in obs] df.addColumns(cols) dfrow = DataRow.fromDict(obs) df.addRow(dfrow) return df
'elem_id': setElem, 'population_size': populationSize, 'success_population': numSuccInPopulation, 'sample_size': sampleSize, 'success_samples': drawnSuccesses, 'pval': pval, 'sample_success_fraction': fractionOfHitSamples, 'genes': ";".join(successIntersection), 'direction': direction } setToResult[setElem] = resultObj sortedElems = [x for x in setToResult] elemPvals = [setToResult[x]["pval"] for x in sortedElems] rej, elemAdjPvals, _, _ = multipletests(elemPvals, alpha=0.05, method='fdr_bh', is_sorted=False, returnsorted=False) for eidx, elem in enumerate(sortedElems): assert (setToResult[elem]['pval'] == elemPvals[eidx]) setToResult[elem]['adj_pval'] = elemAdjPvals[eidx] for elem in sortedElems: dr = DataRow.fromDict(setToResult[elem]) outdf.addRow(dr) outdf.export(args.output.name)
"<a href=\"https://www.ncbi.nlm.nih.gov/pubmed/?term=" + x + "+" + mirna.getStringFromParts([miRNAPART.MATURE, miRNAPART.ID]) + "\">Search PUBMED</a>" "</br><a href=\"" + dianaLink + "\">Search DIANA</a>", 'PubMed': "", 'MIRECORD': '', 'MIRTARBASE': "", 'MIRWALK': "" } row = DataRow.fromDict(addRow) missingDF.addRow(row) linkedDF.addRow(row) print("Total Missing miRNAs", totalMissing) def makeLinks(mylist, lnkFnc): return [lnkFnc(x) for x in mylist] print("Accepted miRNAs") for x in foundAcceptedInteractions: geneCap = x.upper() geneLow = x.lower()
pmidt = getPMIDTitles(ntd) for x in sorted([x for x in pmidt]): dataDict = { 'SET': 'NTinfect', 'PMID_ID': "<a href='https://www.ncbi.nlm.nih.gov/pubmed/" + str(x) + "' target='_blank'>" + str(x) + "</a>", 'PMID_TITLE': pmidt[x], 'Common': x in ntg } res.addRow(DataRow.fromDict(dataDict)) print(x, pmidt[x]) print("\n\n\n\n\n") print(ntg) print("NTG", len(ntg)) pmidt = getPMIDTitles(ntg) for x in sorted([x for x in pmidt]): dataDict = { 'SET': 'NTinflamm', 'PMID_ID': "<a href='https://www.ncbi.nlm.nih.gov/pubmed/" + str(x) + "' target='_blank'>" + str(x) + "</a>",
sample2stats = makeplot(sample2genecount, defile.name, sample2stats, args.output[fidx]) columns = list() for sample in sample2stats: for x in sample2stats[sample]: if not x in columns: columns.append(x) outdf = DataFrame() outdf.addColumns(columns) for sample in sample2stats: dr = DataRow.fromDict(sample2stats[sample]) outdf.addRow(dr) print(outdf) if dfGroups != None: allGenes = set() for sample in sample2genecount: for x in sample2genecount[sample]: allGenes.add(x[0]) for group in dfGroups: for gm in group: if not gm in sample2genecount: print([x for x in sample2genecount])
for pset in allPowerSets: if len(pset) == 0: continue setPMIDs = set([x for x in allPMIDs]) for dim in pset: setPMIDs = setPMIDs.intersection( dbs2pmids[dim] ) print(pset, len(setPMIDs)) drdict = { "Subset": ", ".join(pset), "Number of PMIDs": len(setPMIDs) } dr = DataRow.fromDict(drdict) outdf.addRow(dr) print(outdf._makeLatex())
cellElems.append(elem['name'] + " (" + elem['termid'] + ")") else: for elem in restricts[restrictType]: otherElems.append(elem['name'] + " (" + elem['termid'] + ")") networkDRdict['Cells'] = "\makecell[l]{" + "\\\\".join( sorted(cellElems)) + "}" networkDRdict['Disease'] = "\makecell[l]{" + "\\\\".join( sorted(diseaseElems)) + "}" networkDRdict['Other'] = "\makecell[l]{" + "\\\\".join( sorted(otherElems)) + "}" dr = DataRow.fromDict(networkDRdict) restrictDF.addRow(dr) print(restrictDF._makeLatex()) #exit() allMissing = {} figidx = 0 mirna2cellOut = open("/mnt/d/yanc_network/important_process.txt", 'w') for network in networks: figidx += 1 networkGraph = nx.Graph()
cellElems.append(elem['name'] + " (" + elem['termid'] + ")") else: for elem in restricts[restrictType]: otherElems.append(elem['name'] + " (" + elem['termid'] + ")") networkDRdict['Cells'] = "\makecell[l]{" + "\\\\".join( sorted(cellElems)) + "}" networkDRdict['Disease'] = "\makecell[l]{" + "\\\\".join( sorted(diseaseElems)) + "}" networkDRdict['Other'] = "\makecell[l]{" + "\\\\".join( sorted(otherElems)) + "}" dr = DataRow.fromDict(networkDRdict) restrictDF.addRow(dr) print(restrictDF._makeLatex()) mirna2cellOut = open("/mnt/d/yanc_network/important_networks.txt", 'w') def acceptEvidence(ev): return True figidx = 0 for network in networks: figidx += 1
cells = tuple(sorted(mirna2cells[mirna])) cells2mirnas[cells].add(mirna) for cells in cells2mirnas: ncells = [] for cell in cells: ncells.append( ""+cell+"}" ) rowdict = { 'miRNA': "\\makecell[l]{" + "\\\\".join(sorted(cells2mirnas[cells])) + "}", 'cells': "\\makecell[l]{" + "\\\\".join(cells) + "}" } cellCommunicatorDF.addRow(DataRow.fromDict(rowdict)) cellCommunicatorDF.export("/mnt/d/yanc_network/stage_cells_cliques"+stage+".latex", ExportTYPE.LATEX) cellCommunicatorDF.export("/mnt/d/yanc_network/stage_cells_cliques"+stage+".tsv", ExportTYPE.TSV) CytoscapeGrapher.showGraph(cellgraph, '/mnt/d/yanc_network/', name="stage_cells_" + stage) figidx = CytoscapeGrapher.plotNXGraph(cellgraph, stage, ["/mnt/d/yanc_network/stage_cells_" + stage.replace(" ", "_") + ".png", "/mnt/d/yanc_network/stage_cells_" + stage.replace(" ", "_") + ".pdf"], figidx) print() print() print() print() print()
for org in mc + nmc: rowdict = {'sample': org} for homid in targetHOMIDS: homID = homid val = homDB.get_cluster(homID) if org in val: rowdict[homID] = 1 else: rowdict[homID] = 0 dfrow = DataRow.fromDict(rowdict) df.addRow(dfrow) df.export(outFile=None) print(allorgs) print(len(homClusterIDs)) if len(homClusterIDs) < 10: print(homClusterIDs) orgMatrix = {} for org in mc + nmc: orgRes = []