In [ ]:
import anndata as ad
import ACTIONet as anet
In [ ]:
%load_ext autoreload
%autoreload 2
%aimport ACTIONet
In [ ]:
adata = ad.read_h5ad("../data/pfc5k_ACTIONet_v2_python.h5ad")
In [ ]:
adata
Out[ ]:
AnnData object with n_obs × n_vars = 4505 × 17658
    obs: 'umis', 'genes', 'mito.perc', 'sizeFactors', 'Celltype', 'assigned_archetype', 'node_centrality'
    uns: 'ACTION', '__annotations___colors', 'metadata', 'obsm_annot', 'varm_annot'
    obsm: 'ACTION', 'ACTION_B', 'ACTION_normalized', 'ACTIONet2D', 'ACTIONet3D', 'ACTIONred', 'C_stacked', 'C_unified', 'H_stacked', 'H_unified', 'archetype_footprint', 'denovo_color'
    varm: 'ACTION_A', 'ACTION_V', 'unified_feature_profile', 'unified_feature_specificity'
    obsp: 'ACTIONet'
In [ ]:
anet.po.cells.cluster(adata)
In [ ]:
adata
Out[ ]:
AnnData object with n_obs × n_vars = 4505 × 17658
    obs: 'umis', 'genes', 'mito.perc', 'sizeFactors', 'Celltype', 'assigned_archetype', 'node_centrality', 'leiden'
    uns: 'ACTION', '__annotations___colors', 'metadata', 'obsm_annot', 'varm_annot'
    obsm: 'ACTION', 'ACTION_B', 'ACTION_normalized', 'ACTIONet2D', 'ACTIONet3D', 'ACTIONred', 'C_stacked', 'C_unified', 'H_stacked', 'H_unified', 'archetype_footprint', 'denovo_color'
    varm: 'ACTION_A', 'ACTION_V', 'unified_feature_profile', 'unified_feature_specificity', 'leiden_feature_specificity'
    obsp: 'ACTIONet'
In [ ]:
anet.pl.plot_ACTIONet(adata, "leiden")
Out[ ]:
<AxesSubplot:title={'center':'__annotations__'}, xlabel='actionet2d1', ylabel='actionet2d2'>
In [ ]:
adata.varm["leiden_feature_specificity"].shape
Out[ ]:
(17658, 24)
In [ ]:
import json
import itertools

f = open('../markers.json')

all_markers = json.load(f)

markers = all_markers["Brain"]["PFC"]["Mohammadi2020"]["marker.genes"]
In [ ]:
Labels, Conf, Enrichment = anet.po.clusters.annotate(adata, labels=adata.obs["Celltype"])
In [ ]:
Enrichment
Out[ ]:
Ast Ex-L2 Ex-L23 Ex-L3 Ex-L4_MYLK Ex-L45_LRRK1 Ex-L45_MET Ex-L56 Ex-L56_CC_NTNG2 Ex-L5b_HTR2C ... In-PV_Chandelier In-Reelin In-Rosehip_CHST9 In-Rosehip_TRPC3 In-SST In-VIP Mic Oli OPC Pericytes
11.0 3.405582 -0.667258 -0.688568 -0.667258 -0.688568 -0.667258 -0.667258 -0.688568 -0.688568 -0.709878 ... -0.688568 -0.709878 -0.709878 -0.688568 -0.667258 -0.688568 -0.688568 -0.688568 -0.688568 -0.688568
4.0 0.111224 22.530813 0.799009 0.187077 0.262929 -0.040481 0.035371 0.111224 0.111224 0.187077 ... 0.262929 -0.040481 0.262929 0.035371 0.035371 0.338782 0.262929 -0.419745 0.035371 0.262929
2.0 0.141076 -0.102929 23.893405 2.217638 -0.184264 -0.672273 -0.021594 -0.102929 0.141076 0.059741 ... 0.141076 0.141076 -0.021594 0.141076 0.222411 0.059741 0.141076 -0.672273 -0.021594 0.059741
8.0 -0.697275 -0.730588 -0.830526 5.211136 -0.730588 -0.697275 -0.730588 -0.697275 -0.730588 -0.697275 ... -0.730588 -0.697275 -0.697275 -0.730588 -0.797213 -0.697275 -0.697275 -0.863838 -0.730588 -0.697275
13.0 -0.731660 -0.731660 -0.696954 -0.714307 2.458317 -0.696954 -0.714307 -0.731660 -0.731660 -0.731660 ... -0.731660 -0.714307 -0.731660 -0.731660 -0.731660 -0.714307 -0.731660 -0.731660 -0.731660 -0.731660
3.0 -0.781591 -1.237237 -1.541001 -0.933473 -0.857532 34.613312 -0.857532 -1.085355 -0.857532 -0.781591 ... -1.009414 -0.857532 -0.933473 -0.857532 -1.085355 -1.009414 -0.933473 -1.161296 -0.781591 -0.933473
7.0 -0.778979 -0.706337 -0.815300 -0.742658 -0.778979 -0.778979 8.315611 -0.778979 -0.778979 -0.778979 ... -0.778979 -0.778979 -0.778979 -0.778979 -0.815300 -0.778979 -0.778979 -0.742658 -0.778979 -0.778979
18.0 -0.683859 -0.683859 -0.683859 -0.683859 -0.683859 -0.695017 -0.683859 1.459370 -0.683859 -0.683859 ... -0.683859 -0.683859 -0.695017 -0.683859 -0.683859 -0.683859 -0.683859 -0.683859 -0.683859 -0.683859
20.0 -0.692983 -0.692983 -0.692983 -0.692983 -0.692983 -0.692983 -0.692983 -0.692983 1.151918 -0.692983 ... -0.692983 -0.692983 -0.692983 -0.692983 -0.692983 -0.692983 -0.692983 -0.692983 -0.692983 -0.692983
19.0 -0.698303 -0.688275 -0.688275 -0.688275 -0.688275 -0.688275 -0.688275 -0.688275 -0.688275 1.314992 ... -0.688275 -0.688275 -0.688275 -0.688275 -0.688275 -0.688275 -0.688275 -0.698303 -0.688275 -0.688275
22.0 -0.702556 -0.702556 -0.706502 -0.702556 -0.702556 -0.702556 -0.702556 -0.702556 -0.702556 -0.702556 ... -0.702556 -0.702556 -0.702556 -0.702556 -0.702556 -0.702556 -0.702556 -0.702556 -0.702556 -0.702556
5.0 -0.759648 -0.759648 -0.800959 -0.635715 -0.759648 -0.635715 -0.759648 -0.842270 -0.759648 -0.842270 ... -0.800959 -0.759648 -0.800959 -0.800959 -0.883581 -0.842270 -0.759648 -0.635715 -0.759648 -0.759648
12.0 -0.688568 -0.688568 -0.731188 -0.709878 -0.688568 -0.709878 -0.709878 -0.688568 -0.688568 -0.688568 ... -0.688568 -0.688568 -0.709878 -0.688568 -0.709878 -0.688568 -0.688568 -0.709878 -0.688568 -0.688568
16.0 -0.674513 -0.674513 -0.687618 -0.674513 -0.674513 -0.674513 -0.674513 -0.687618 -0.674513 -0.674513 ... -0.674513 -0.674513 -0.674513 -0.674513 -0.674513 -0.674513 -0.674513 -0.687618 -0.674513 -0.674513
24.0 -0.704911 -0.704911 -0.704911 -0.704911 -0.704911 -0.704911 -0.704911 -0.704911 -0.704911 -0.704911 ... -0.704911 -0.704911 -0.704911 -0.704911 -0.704911 -0.704911 -0.704911 -0.704911 -0.704911 0.716167
9.0 -0.670419 -0.637441 -0.670419 -0.670419 -0.703397 -0.769353 -0.670419 -0.670419 -0.670419 -0.670419 ... -0.670419 -0.703397 -0.670419 -0.670419 -0.703397 -0.670419 -0.670419 -0.703397 -0.670419 -0.670419
21.0 -0.701115 -0.701115 -0.701115 -0.701115 -0.701115 -0.701115 -0.701115 -0.701115 -0.701115 -0.701115 ... 0.850559 -0.701115 -0.701115 -0.701115 -0.701115 -0.701115 -0.701115 -0.701115 -0.701115 -0.701115
15.0 -0.712111 -0.712111 -0.698355 -0.712111 -0.712111 -0.712111 -0.712111 -0.712111 -0.712111 -0.712111 ... -0.712111 1.846954 -0.712111 -0.712111 -0.725867 -0.725867 -0.712111 -0.698355 -0.712111 -0.712111
14.0 -0.753175 -0.738441 -0.723708 -0.738441 -0.738441 -0.723708 -0.738441 -0.738441 -0.738441 -0.738441 ... -0.738441 -0.738441 1.187825 1.526705 -0.738441 -0.738441 -0.738441 -0.723708 -0.738441 -0.738441
6.0 -0.950310 -0.950310 -0.987299 -0.987299 -0.950310 -0.987299 -1.098265 -0.987299 -0.950310 -0.950310 ... -0.950310 -0.987299 -0.950310 -0.950310 8.588473 -1.024287 -0.987299 -0.987299 -0.987299 -0.987299
10.0 -0.824359 -0.767098 -0.824359 -0.767098 -0.738467 -0.681207 -0.767098 -0.767098 -0.738467 -0.738467 ... -0.738467 -0.738467 -0.738467 -0.767098 -0.767098 5.505428 -0.738467 -0.767098 -0.738467 -0.738467
23.0 -0.704735 -0.704735 -0.704735 -0.704735 -0.704735 -0.704735 -0.704735 -0.704735 -0.704735 -0.704735 ... -0.704735 -0.704735 -0.704735 -0.704735 -0.704735 -0.704735 0.734496 -0.704735 -0.704735 -0.704735
1.0 -0.740123 -1.158995 -1.912964 -1.242769 -1.075220 -1.996738 -0.991446 -0.572574 -0.488800 -0.740123 ... -0.488800 -0.488800 -0.740123 -0.740123 -0.991446 -0.740123 -0.572574 47.109213 -0.572574 -0.572574
17.0 -0.681006 -0.681006 -0.681006 -0.681006 -0.692812 -0.692812 -0.692812 -0.681006 -0.681006 -0.681006 ... -0.681006 -0.681006 -0.681006 -0.681006 -0.681006 -0.681006 -0.681006 -0.681006 1.548759 -0.681006

24 rows × 26 columns

In [ ]:
anet.pl.plot_ACTIONet(adata, Labels[adata.obs["leiden"]].values)
Out[ ]:
<AxesSubplot:title={'center':'__annotations__'}, xlabel='actionet2d1', ylabel='actionet2d2'>
In [ ]:
Labels_markers, Conf_markers, Enrichment_markers = anet.po.clusters.annotate(adata, markers=markers)
In [ ]:
Enrichment_markers
Out[ ]:
Ast Endo Ex-L2/3 Ex-L4 Ex-L4/5 Ex-L5 Ex-L5/6 Ex-L5/6-CC Ex-NRGN In-PV (Basket) In-PV (Chandelier) In-Rosehip In-SST In-VIP Mic Oli OPC
1 15.394150 4.209130 0.000000 0.000000 0.000000 0.000000 0.138248 0.000000 2.511525 0.054824 2.158547 2.597149 0.006517 1.924222 5.757794 144.933974 26.585292
2 1.981659 1.140250 22.516059 5.571321 0.831420 1.175309 0.368822 4.701631 0.000000 0.629160 0.210574 0.443293 0.000000 0.000000 0.000000 0.000000 1.735295
3 0.370223 1.633729 1.820932 19.738515 39.382365 13.829256 15.654666 6.352026 4.207010 3.087833 2.190240 4.773742 0.847272 1.873857 0.822734 0.000000 0.991724
4 4.474801 0.252299 78.556095 16.425230 4.537984 12.815258 7.231385 9.899469 0.000000 12.687081 14.584775 18.193452 8.436412 13.630423 0.410144 0.000000 5.948685
5 0.156442 0.270274 5.384564 3.760954 3.124410 8.241191 1.984812 13.713701 0.230896 0.227119 0.028215 1.329750 0.626594 0.000000 0.000000 0.000000 1.162391
6 4.656426 2.156005 4.239376 5.747685 2.182432 7.743715 14.581962 0.748563 1.108005 53.604777 36.070912 39.789054 72.894800 31.054122 1.936827 0.385981 15.043948
7 1.209458 1.791160 5.807342 39.193651 10.286569 7.553017 12.336539 4.027887 4.440934 7.519963 6.712472 6.180313 1.935380 5.993167 0.394853 0.000000 2.233264
8 1.256028 1.627801 9.183055 13.040337 4.049723 1.438213 3.351026 1.734042 0.000000 1.482424 1.583867 2.182761 1.604098 0.343471 0.019181 0.000000 2.167136
9 3.281243 3.974210 0.030788 1.024558 1.655498 6.654433 8.717474 0.803986 0.000000 94.672484 55.020872 34.507691 30.365391 23.513955 2.530164 0.000000 9.427539
10 8.733057 0.556252 0.659323 1.947523 1.758424 4.589595 15.189854 1.099076 1.478197 36.672921 37.681461 42.079320 22.580012 84.061016 1.342639 0.025022 16.334163
11 114.244923 10.298068 0.000000 0.000000 0.000000 1.730309 1.121682 0.001570 0.000000 2.138966 6.755973 7.392946 2.344614 4.872946 7.626039 4.544236 29.392333
12 4.529383 2.151162 2.390445 1.937531 6.148457 28.945045 9.809437 4.439542 0.000000 1.540471 1.071519 2.450919 2.983404 0.756368 3.307817 0.072226 2.509960
13 0.974230 0.734605 6.255705 33.576509 9.449014 6.409674 12.597226 4.642654 0.531595 6.057721 6.554921 7.086450 4.612553 6.295407 1.345893 0.000000 3.105305
14 4.226015 2.384255 0.140703 1.885090 2.735604 2.029807 8.524461 0.167383 0.000000 25.616351 25.911472 74.376641 22.166197 22.666300 1.281536 0.506378 10.893845
15 4.790830 2.031694 0.007945 2.764154 2.587506 2.666144 10.363332 0.333377 0.020355 26.369604 27.223316 42.879845 20.665457 48.267201 1.779537 0.673065 11.159933
16 3.889499 0.624393 5.255826 6.279942 6.497175 29.666479 14.725295 6.053695 0.000000 5.766070 5.689129 3.908025 2.910336 2.639494 1.527736 0.147607 2.781318
17 33.441447 7.911359 0.100675 0.448483 1.219176 4.680882 11.917013 0.042639 0.000000 13.769092 22.466892 19.343245 13.196777 16.075275 6.991092 10.783890 108.773899
18 0.723849 1.328752 1.552857 16.966137 8.482796 5.352669 5.834301 5.612136 1.105329 2.115608 2.906178 3.273873 0.564978 2.169645 2.894328 0.000230 1.973896
19 2.308150 0.551261 0.470084 8.356521 10.246023 12.358176 61.448724 2.105613 0.343495 8.984432 13.001600 9.572191 7.912800 6.138261 1.382999 0.000000 5.908981
20 1.591137 2.186767 2.764857 3.259050 1.940032 6.842987 5.349861 12.594544 0.000000 4.502295 5.054379 4.370866 0.913828 3.357639 1.319800 0.000000 2.101387
21 6.296792 4.699906 1.383938 3.845306 2.790280 5.487682 13.764173 1.259223 0.949783 63.396873 95.151608 40.058467 24.179390 26.699883 3.765619 0.173887 14.283022
22 0.948905 1.400912 3.075238 0.958430 2.171977 4.260208 5.871414 2.714428 0.000000 4.638876 3.541828 4.906900 1.038771 0.885533 0.163836 0.026763 1.302474
23 5.275376 12.280622 0.000000 0.000000 0.234245 0.154707 0.308751 0.000000 0.708596 0.592038 0.809639 0.848527 0.000000 0.080379 77.368820 1.314119 5.110460
24 6.080434 54.712075 0.604174 2.442943 1.174400 0.551448 0.362051 0.407784 98.936826 0.095425 0.914473 1.260935 0.020459 0.227567 0.474639 0.065998 0.130872
In [ ]:
anet.pl.plot_ACTIONet(adata, Labels_markers[adata.obs["leiden"]].values)
Out[ ]:
<AxesSubplot:title={'center':'__annotations__'}, xlabel='actionet2d1', ylabel='actionet2d2'>