Spaces:
Runtime error
Runtime error
Commit ·
68f2aa3
1
Parent(s): edd3b86
fix tf ko
Browse files
app.py
CHANGED
|
@@ -359,9 +359,13 @@ def perturb(gene, locus1, locus2, use_max_gene, tf_knockout):
|
|
| 359 |
|
| 360 |
perterbed_rna_recon = glue.decode_data("rna", "rna", rna, guidance_hvf)
|
| 361 |
ism = np.log2((perterbed_rna_recon + eps) / (rna_recon + eps))
|
|
|
|
| 362 |
max_gene_idx = np.abs(np.mean(ism, axis=0)).argmax()
|
| 363 |
max_gene = rna.var.query(f"highly_variable").index[max_gene_idx]
|
| 364 |
print('Max gene:', max_gene)
|
|
|
|
|
|
|
|
|
|
| 365 |
# get integer index of gene
|
| 366 |
if use_max_gene:
|
| 367 |
gene_idx = gene_idx_map[max_gene]
|
|
@@ -381,7 +385,10 @@ def perturb(gene, locus1, locus2, use_max_gene, tf_knockout):
|
|
| 381 |
legend_fontoutline=2,
|
| 382 |
frameon=False,
|
| 383 |
return_fig=True)
|
| 384 |
-
|
|
|
|
|
|
|
|
|
|
| 385 |
#fig.tight_layout()
|
| 386 |
#fig.patch.set_facecolor('none')
|
| 387 |
#fig.patch.set_alpha(0.0)
|
|
@@ -456,15 +463,15 @@ with gr.Blocks(theme='WeixuanYuan/Soft_dark') as demo:
|
|
| 456 |
outputs = [out_img, out_violin, out_violin_new, out_violin_fc]
|
| 457 |
|
| 458 |
gr.Examples(examples=[['INS', 'chr11:2,289,895', 'chr11:2,298,840', False],
|
| 459 |
-
|
| 460 |
['IRX2', 'chr5:2704405', 'chr5:2164879', False],
|
| 461 |
['TSPAN1', 'TSPAN1', 'PIK3R3', False],
|
| 462 |
-
|
| 463 |
['GCG', 'GCG', 'FAP', False],
|
| 464 |
-
|
| 465 |
['LOXL4', 'chr10:100186215', 'chr10:99913493', False],
|
| 466 |
-
|
| 467 |
-
|
| 468 |
['MAFB', 'chr20:39431654', 'chr20:39368271', True],
|
| 469 |
['CEL', 'chr9:135,937,365', 'chr9:135,973,107', False]],
|
| 470 |
inputs=inputs,
|
|
|
|
| 359 |
|
| 360 |
perterbed_rna_recon = glue.decode_data("rna", "rna", rna, guidance_hvf)
|
| 361 |
ism = np.log2((perterbed_rna_recon + eps) / (rna_recon + eps))
|
| 362 |
+
max_gene_idxs = np.abs(np.mean(ism, axis=0)).argsort()[::-1][:10]
|
| 363 |
max_gene_idx = np.abs(np.mean(ism, axis=0)).argmax()
|
| 364 |
max_gene = rna.var.query(f"highly_variable").index[max_gene_idx]
|
| 365 |
print('Max gene:', max_gene)
|
| 366 |
+
for max_gene_idx in max_gene_idxs:
|
| 367 |
+
max_gene = rna.var.query(f"highly_variable").index[max_gene_idx]
|
| 368 |
+
print(max_gene, np.mean(ism[:, max_gene_idx]))
|
| 369 |
# get integer index of gene
|
| 370 |
if use_max_gene:
|
| 371 |
gene_idx = gene_idx_map[max_gene]
|
|
|
|
| 385 |
legend_fontoutline=2,
|
| 386 |
frameon=False,
|
| 387 |
return_fig=True)
|
| 388 |
+
if tf_knockout:
|
| 389 |
+
fig.suptitle(f'{max_gene if use_max_gene else gene} expression after TF knockout of {gene}')
|
| 390 |
+
else:
|
| 391 |
+
fig.suptitle(f'{max_gene if use_max_gene else gene} expression after removing ' + a1 + '-' + a2)
|
| 392 |
#fig.tight_layout()
|
| 393 |
#fig.patch.set_facecolor('none')
|
| 394 |
#fig.patch.set_alpha(0.0)
|
|
|
|
| 463 |
outputs = [out_img, out_violin, out_violin_new, out_violin_fc]
|
| 464 |
|
| 465 |
gr.Examples(examples=[['INS', 'chr11:2,289,895', 'chr11:2,298,840', False],
|
| 466 |
+
# ['OTUD3', 'chr1:20457786', 'chr1:20230413', False],
|
| 467 |
['IRX2', 'chr5:2704405', 'chr5:2164879', False],
|
| 468 |
['TSPAN1', 'TSPAN1', 'PIK3R3', False],
|
| 469 |
+
# ['IRX1', 'chr5:5397612', 'chr5:4850008', False],
|
| 470 |
['GCG', 'GCG', 'FAP', False],
|
| 471 |
+
# ['GCG', 'chr2:163162903', 'chr2:162852164', True],
|
| 472 |
['LOXL4', 'chr10:100186215', 'chr10:99913493', False],
|
| 473 |
+
# ['KRT19', 'chr17:22,220,637', 'chr17:39,591,813', False],
|
| 474 |
+
# ['LPP', 'chr3:188,097,749', 'chr3:197,916,262', False],
|
| 475 |
['MAFB', 'chr20:39431654', 'chr20:39368271', True],
|
| 476 |
['CEL', 'chr9:135,937,365', 'chr9:135,973,107', False]],
|
| 477 |
inputs=inputs,
|