Reference
This part of the project documentation focuses on
an information-oriented approach. Use it as a
reference for the technical implementation of the
linmo
project code.
linmo.resample
Provides functions for resampling tree datasets.
This module contains the following functions:
sort_align_tree
- Sorts and aligns trees.read_dataset
- Returns sorted tree dataset.resample_trees_doublets
- Returns subtree dictionary and DataFrame containing number of doublets across all resamples, the original trees, and the expected number (solved analytically).resample_trees_triplets
- Returns subtree dictionary and DataFrame containing number of triplets across all resamples, the original trees, and the expected number (solved analytically).resample_trees_quartets
- Returns subtree dictionary and DataFrame containing number of quartets across all resamples, the original trees, and the expected number (solved analytically).resample_trees_asym_quartets
- Returns subtree dictionary and DataFrame containing number of asymmetric quartets across all resamples, the original trees, and the expected number (solved analytically).resample_trees_asym_quintets
- Returns subtree dictionary and DataFrame containing number of asymmetric quintets across all resamples, the original trees, and the expected number (solved analytically).resample_trees_asym_sextets
- Returns subtree dictionary and DataFrame containing number of asymmetric sextets across all resamples, the original trees, and the expected number (solved analytically).resample_trees_asym_septets
- Returns subtree dictionary and DataFrame containing number of asymmetric septets across all resamples, the original trees, and the expected number (solved analytically).resample_trees_sextets
- Returns subtree dictionary and DataFrame containing number of sextets across all resamples, the original trees, and the expected number (solved analytically).resample_trees_octets
- Returns subtree dictionary and DataFrame containing number of octets across all resamples, the original trees, and the expected number (solved analytically).multi_dataset_resample_trees
- Returns subtree dictionary and DataFrame containing number of a defined subtree type across all resamples, the original trees, and the expected number (solved analytically) across all datasets.
multi_dataset_resample_trees(datasets, dataset_names, subtree, num_resamples=10000, replacement_bool=True, cell_fates='auto')
Performs resampling of trees, drawing with or without replacement, returning number of subtrees across all resamples, the original trees, and the expected number (solved analytically) for multiple datasets. The cell fates used are the composite set across all datasets provided.
Resampling is done as described in each of the resample_trees_subtrees
functions.
If cell_fates
not explicitly provided, use automatically determined cell fates based on tree datasets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datasets |
list
|
List where each entry is a path to txt file of dataset. txt file should be formatted as NEWICK trees separated with semi-colons and no spaces |
required |
dataset_names |
list
|
List where each entry is a string representing the dataset label. |
required |
subtree |
string
|
type of subtree to be analyzed. Should be 'doublet', 'triplet', or 'quartet'. |
required |
num_resamples |
int
|
Number of resample datasets. |
10000
|
replacement_bool |
bool
|
Sample cells with or without replacement drawing from the pool of all cells. |
True
|
cell_fates |
string or list
|
If 'auto' (i.e. not provided by user), automatically determined based on tree dataset. User can also provide list where each entry is a string representing a cell fate. |
'auto'
|
Returns:
Type | Description |
---|---|
tuple
|
Contains the following variables. |
|
|
|
|
|
Source code in linmo/resample.py
2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 |
|
read_dataset(path)
Reads dataset txt file located at path
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
string
|
Path to txt file of dataset. txt file should be formatted as NEWICK trees separated with semi-colons and no spaces. |
required |
Returns:
Name | Type | Description |
---|---|---|
all_trees_sorted |
list
|
List where each entry is a string representing a tree in NEWICK format.
Trees are sorted using the |
Source code in linmo/resample.py
resample_trees_asym_quartets(all_trees_sorted, num_resamples=10000, replacement_bool=True, cell_fates='auto', calc_expected=True)
Performs resampling of tree, drawing with or without replacement, returning subtree dictionary and DataFrame containing number of asymmetric quartets across all resamples, the original trees, and the expected number (solved analytically).
Resampling is done via (1) replacing each triplet with a randomly chosen triplet across all trees and
(2) replacing every other cell with a randomly chosen non-triplet cell across all trees.
If cell_fates
not explicitly provided, use automatically determined cell fates based on tree dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
all_trees_sorted |
list
|
List where each entry is a string representing a tree in NEWICK format.
Trees are sorted using the |
required |
num_resamples |
int
|
Number of resample datasets. |
10000
|
replacement_bool |
bool
|
Sample cells with or without replacement drawing from the pool of all cells. |
True
|
cell_fates |
string or list
|
If 'auto' (i.e. not provided by user), automatically determined based on tree dataset. User can also provide list where each entry is a string representing a cell fate. |
'auto'
|
calc_expected |
Boolean
|
Calculate expected count if True by multiplying the marginal probabilities of each sub-pattern by the total number of subtrees |
True
|
Returns:
Type | Description |
---|---|
tuple
|
Contains the following variables. |
|
|
|
|
|
Source code in linmo/resample.py
1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 |
|
resample_trees_asym_quintets(all_trees_sorted, num_resamples=10000, replacement_bool=True, cell_fates='auto', calc_expected=True)
Performs resampling of tree, drawing with or without replacement, returning subtree dictionary and DataFrame containing number of asymmetric quartets across all resamples, the original trees, and the expected number (solved analytically).
Resampling is done via (1) replacing each asymmetric quartet with a randomly chosen asymmetric quartet across all trees and
(2) replacing every other cell with a randomly chosen non-asymmetric quartet cell across all trees.
If cell_fates
not explicitly provided, use automatically determined cell fates based on tree dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
all_trees_sorted |
list
|
List where each entry is a string representing a tree in NEWICK format.
Trees are sorted using the |
required |
num_resamples |
int
|
Number of resample datasets. |
10000
|
replacement_bool |
bool
|
Sample cells with or without replacement drawing from the pool of all cells. |
True
|
cell_fates |
string or list
|
If 'auto' (i.e. not provided by user), automatically determined based on tree dataset. User can also provide list where each entry is a string representing a cell fate. |
'auto'
|
calc_expected |
Boolean
|
Calculate expected count if True by multiplying the marginal probabilities of each sub-pattern by the total number of subtrees |
True
|
Returns:
Type | Description |
---|---|
tuple
|
Contains the following variables. |
|
|
|
|
|
Source code in linmo/resample.py
1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 |
|
resample_trees_asym_septets(all_trees_sorted, num_resamples=10000, replacement_bool=True, cell_fates='auto', calc_expected=True)
Performs resampling of tree, drawing with or without replacement, returning subtree dictionary and DataFrame containing number of asymmetric septets across all resamples, the original trees, and the expected number (solved analytically).
Resampling is done via (1) replacing each asymmetric sextet with a randomly chosen asymmetric sextet across all trees and
(2) replacing every other cell with a randomly chosen non-asymmetric sextet cell across all trees.
If cell_fates
not explicitly provided, use automatically determined cell fates based on tree dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
all_trees_sorted |
list
|
List where each entry is a string representing a tree in NEWICK format.
Trees are sorted using the |
required |
num_resamples |
int
|
Number of resample datasets. |
10000
|
replacement_bool |
bool
|
Sample cells with or without replacement drawing from the pool of all cells. |
True
|
cell_fates |
string or list
|
If 'auto' (i.e. not provided by user), automatically determined based on tree dataset. User can also provide list where each entry is a string representing a cell fate. |
'auto'
|
calc_expected |
Boolean
|
Calculate expected count if True by multiplying the marginal probabilities of each sub-pattern by the total number of subtrees |
True
|
Returns:
Type | Description |
---|---|
tuple
|
Contains the following variables. |
|
|
|
|
|
Source code in linmo/resample.py
2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 |
|
resample_trees_asym_sextets(all_trees_sorted, num_resamples=10000, replacement_bool=True, cell_fates='auto', calc_expected=True)
Performs resampling of tree, drawing with or without replacement, returning subtree dictionary and DataFrame containing number of asymmetric quintets across all resamples, the original trees, and the expected number (solved analytically).
Resampling is done via (1) replacing each asymmetric quintet with a randomly chosen asymmetric quintet across all trees and
(2) replacing every other cell with a randomly chosen non-asymmetric quintet cell across all trees.
If cell_fates
not explicitly provided, use automatically determined cell fates based on tree dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
all_trees_sorted |
list
|
List where each entry is a string representing a tree in NEWICK format.
Trees are sorted using the |
required |
num_resamples |
int
|
Number of resample datasets. |
10000
|
replacement_bool |
bool
|
Sample cells with or without replacement drawing from the pool of all cells. |
True
|
cell_fates |
string or list
|
If 'auto' (i.e. not provided by user), automatically determined based on tree dataset. User can also provide list where each entry is a string representing a cell fate. |
'auto'
|
calc_expected |
Boolean
|
Calculate expected count if True by multiplying the marginal probabilities of each sub-pattern by the total number of subtrees |
True
|
Returns:
Type | Description |
---|---|
tuple
|
Contains the following variables. |
|
|
|
|
|
Source code in linmo/resample.py
1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 |
|
resample_trees_doublets(all_trees_sorted, num_resamples=10000, replacement_bool=True, cell_fates='auto', calc_expected=True)
Performs resampling of trees, drawing with or without replacement, returning subtree dictionary and DataFrame containing number of doublets across all resamples, the original trees, and the expected number (solved analytically).
Resampling is done by replacing each cell fate with a randomly chosen cell fate across all trees.
If cell_fates
not explicitly provided, use automatically determined cell fates based on tree dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
all_trees_sorted |
list
|
List where each entry is a string representing a tree in NEWICK format.
Trees are sorted using the |
required |
num_resamples |
int
|
Number of resample datasets. |
10000
|
replacement_bool |
bool
|
Sample cells with or without replacement drawing from the pool of all cells. |
True
|
cell_fates |
string or list
|
If 'auto' (i.e. not provided by user), automatically determined based on tree dataset. User can also provide list where each entry is a string representing a cell fate. |
'auto'
|
calc_expected |
Boolean
|
Calculate expected count if True by multiplying the marginal probabilities of each sub-pattern by the total number of subtrees |
True
|
Returns:
Type | Description |
---|---|
tuple
|
Contains the following variables. |
|
|
|
|
|
Source code in linmo/resample.py
resample_trees_octets(all_trees_sorted, num_resamples=10000, replacement_bool=True, cell_fates='auto', calc_expected=True)
Performs resampling of tree, drawing with or without replacement, returning subtree dictionary and DataFrame containing the number of octets across all resamples, the original trees, and the expected number (solved analytically).
Resampling is done via replacing each quartet with a randomly chosen quartet from across all trees.
If cell_fates
not explicitly provided, use automatically determined cell fates based on tree dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
all_trees_sorted |
list
|
List where each entry is a string representing a tree in NEWICK format.
Trees are sorted using the |
required |
num_resamples |
int
|
Number of resample datasets. |
10000
|
replacement_bool |
bool
|
Sample cells with or without replacement drawing from the pool of all cells. |
True
|
cell_fates |
string or list
|
If 'auto' (i.e. not provided by user), automatically determined based on tree dataset. User can also provide list where each entry is a string representing a cell fate. |
'auto'
|
calc_expected |
Boolean
|
Calculate expected count if True by multiplying the marginal probabilities of each sub-pattern by the total number of subtrees |
True
|
Returns:
Type | Description |
---|---|
tuple
|
Contains the following variables. |
|
|
|
|
|
Source code in linmo/resample.py
2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 |
|
resample_trees_quartets(all_trees_sorted, num_resamples=10000, replacement_bool=True, cell_fates='auto', calc_expected=True)
Performs resampling of tree, drawing with or without replacement, returning subtree dictionary and DataFrame containing the number of quartets across all resamples, the original trees, and the expected number (solved analytically).
Resampling is done via replacing each doublet with a randomly chosen doublet from across all trees.
If cell_fates
not explicitly provided, use automatically determined cell fates based on tree dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
all_trees_sorted |
list
|
List where each entry is a string representing a tree in NEWICK format.
Trees are sorted using the |
required |
num_resamples |
int
|
Number of resample datasets. |
10000
|
replacement_bool |
bool
|
Sample cells with or without replacement drawing from the pool of all cells. |
True
|
cell_fates |
string or list
|
If 'auto' (i.e. not provided by user), automatically determined based on tree dataset. User can also provide list where each entry is a string representing a cell fate. |
'auto'
|
calc_expected |
Boolean
|
Calculate expected count if True by multiplying the marginal probabilities of each sub-pattern by the total number of subtrees |
True
|
Returns:
Type | Description |
---|---|
tuple
|
Contains the following variables. |
|
|
|
|
|
Source code in linmo/resample.py
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 |
|
resample_trees_sextets(all_trees_sorted, num_resamples=10000, replacement_bool=True, cell_fates='auto', calc_expected=True)
Performs resampling of tree, drawing with or without replacement, returning subtree dictionary and DataFrame containing number of sextets across all resamples, the original trees, and the expected number (solved analytically).
Resampling is done via (1) replacing each quartet with a randomly chosen quartet across all trees and
(2) replacing every other doublet with a randomly chosen non-quartet doublet across all trees.
If cell_fates
not explicitly provided, use automatically determined cell fates based on tree dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
all_trees_sorted |
list
|
List where each entry is a string representing a tree in NEWICK format.
Trees are sorted using the |
required |
num_resamples |
int
|
Number of resample datasets. |
10000
|
replacement_bool |
bool
|
Sample cells with or without replacement drawing from the pool of all cells. |
True
|
cell_fates |
string or list
|
If 'auto' (i.e. not provided by user), automatically determined based on tree dataset. User can also provide list where each entry is a string representing a cell fate. |
'auto'
|
calc_expected |
Boolean
|
Calculate expected count if True by multiplying the marginal probabilities of each sub-pattern by the total number of subtrees |
True
|
Returns:
Type | Description |
---|---|
tuple
|
Contains the following variables. |
|
|
|
|
|
Source code in linmo/resample.py
2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 |
|
resample_trees_triplets(all_trees_sorted, num_resamples=10000, replacement_bool=True, cell_fates='auto', calc_expected=True)
Performs resampling of tree, drawing with or without replacement, returning subtree dictionary and DataFrame containing number of triplets across all resamples, the original trees, and the expected number (solved analytically).
Resampling is done via (1) replacing each cell with a randomly chosen non_doublet across all trees and
(2) replacing each doublet with a randomly chosen doublet across all trees.
If cell_fates
not explicitly provided, use automatically determined cell fates based on tree dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
all_trees_sorted |
list
|
List where each entry is a string representing a tree in NEWICK format.
Trees are sorted using the |
required |
num_resamples |
int
|
Number of resample datasets. |
10000
|
replacement_bool |
bool
|
Sample cells with or without replacement drawing from the pool of all cells. |
True
|
cell_fates |
string or list
|
If 'auto' (i.e. not provided by user), automatically determined based on tree dataset. User can also provide list where each entry is a string representing a cell fate. |
'auto'
|
calc_expected |
Boolean
|
Calculate expected count if True by multiplying the marginal probabilities of each sub-pattern by the total number of subtrees |
True
|
Returns:
Type | Description |
---|---|
tuple
|
Contains the following variables. |
|
|
|
|
|
Source code in linmo/resample.py
sort_align_tree(tree)
Sort and align provided tree.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tree |
string
|
Tree in NEWICK format. |
required |
Returns:
Name | Type | Description |
---|---|---|
tree |
string
|
Tree in NEWICK format. Trees are sorted to have all asymmetric septets in (x,(x,(x,(x,(x,(x,x)))))) format, asymmetric sextets in (x,(x,(x,(x,(x,x))))) format, asymmetric quintets in (x,(x,(x,(x,x)))), asymmetric quartets in (x,(x,(x,x))) format, triplets in (x,(x,x)) format, and all octets/quartets/doublets in alphabetical order. |
Source code in linmo/resample.py
linmo.plot
Provides functions for visualizing motif analysis.
This module contains the following functions:
dfs_for_plotting
- Takes DataFrame fromresample_trees
functions and returns DataFrame for plotting.make_cell_color_dict
- Returns cell color dictionary based on provided cell fates.plot_frequency
- Displays frequency plot ofcutoff
number of subtrees in original dataset and all resamples.plot_deviation
- Displays deviation plot ofcutoff
number of subtrees in original dataset and a subset of resamples.multi_dataset_dfs_for_plotting
- Takes DataFrame frommulti_dataset_resample_trees
function and returns DataFrames for plotting.multi_dataset_plot_deviation
- Displays deviation plot ofcutoff
number of subtrees in multiple datasets.
dfs_for_plotting(dfs_c, num_resamples, subtree_dict, cutoff='auto', num_null=1000, use_expected=True, min_cell_types=1)
Converts DataFrame from resample_trees functions into DataFrames for plotting.
Calculates z-scores by comparing the observed count in the original trees to the mean/std across all resamples.
Calculates null z-scores by comparing the observed count of num_null
random resamples to the mean/std across the rest of
the resamples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dfs_c |
DataFrame
|
Indexed by values from |
required |
num_resamples |
int
|
Number of resamples. |
required |
subtree_dict |
dict
|
Keys are subtrees, values are integers. |
required |
cutoff |
string or NoneType or int
|
Take |
'auto'
|
num_null |
int
|
Take |
1000
|
use_expected |
Boolean
|
Use expected count in DataFrame. |
True
|
min_cell_types |
int
|
Use subtrees with only a minimal amount of different cell types. |
1
|
Returns:
Type | Description |
---|---|
tuple
|
Contains the following variables. |
|
|
|
|
|
|
|
|
|
|
|
Source code in linmo/plot.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
make_color_dict(labels, colors)
Makes color dictionary based on provided labels (can be cell types or dataset names).
If cell_fates not provided, use automatically determined cell fates based on tree dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
- |
labels (list
|
List of string labels. |
required |
- |
colors (list
|
List of string color codes. |
required |
Returns:
Name | Type | Description |
---|---|---|
color_dict |
dict
|
Keys are labels, values are colors. |
Source code in linmo/plot.py
multi_dataset_dfs_for_plotting(dfs_dataset_c, dataset_names, num_resamples, subtree_dict, cutoff='auto', num_null=1000)
Converts DataFrame from multi_dataset_resample_trees
function into DataFrames for plotting.
Calculates z-scores by comparing the observed count in the original trees to the mean/std across all resamples.
Calculates null z-scores by comparing the observed count of num_null
random resamples to the mean/std across the rest of
the resamples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dfs_dataset_c |
list
|
List where each entry is a DataFrame with the following characteristics.
Indexed by values from |
required |
dataset_names |
list
|
List where each entry is a string representing the dataset label. |
required |
num_resamples |
int
|
Number of resamples. |
required |
subtree_dict |
dict
|
Keys are subtrees, values are integers. |
required |
cutoff |
string or NoneType or int
|
Takes |
'auto'
|
num_null |
int
|
Takes |
1000
|
Returns:
Type | Description |
---|---|
tuple
|
Contains the following DataFrames. |
|
|
|
|
|
|
|
|
|
Source code in linmo/plot.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 |
|
multi_dataset_plot_deviation(subtree, dataset_names, df_true_melt_dataset_label_c_c, dataset_color_dict, cell_color_dict, cutoff='auto', title='auto', legend_bool=True, legend_pos='outside', save=False, image_format='png', dpi=300, image_save_path=None)
Plots deviation of cutoff
number of subtrees in multiple datasets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subtree |
string
|
Type of subtree. |
required |
dataset_names |
list
|
List where each entry is a string representing the dataset label. |
required |
df_true_melt_dataset_label_c_c |
DataFrame
|
DataFrame with cutoff number of most significant subtrees for plotting.
Sorted by z-score from most over-represented to most under-represented.
Output from |
required |
dataset_color_dict |
dict
|
Keys are dataset names, values are colors. |
required |
cell_color_dict |
dict
|
Keys are cell fates, values are colors. |
required |
cutoff |
string or NoneType or int
|
Take |
'auto'
|
title |
string
|
Title to use for plot. If not provided explicitly, will be automatically determined to read |
'auto'
|
legend_bool |
bool
|
Include legend in plot. |
True
|
legend_pos |
string
|
Position of legend (outside or inside). |
'outside'
|
save |
bool
|
If True, save figure as file. |
False
|
image |
format (string
|
Format of image file to be saved (png or svg). |
required |
dpi |
int
|
Resolution of saved image file. |
300
|
image_save_path |
string
|
Path to saved image file. |
None
|
Source code in linmo/plot.py
910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 |
|
plot_deviation(subtree, df_true_melt_subset, df_null_zscores_i_c_melt_subset, df_null_zscores_i_c_melt_100resamples_subset, cell_color_dict, fdr_type='fdr_tsbh', cutoff='auto', title='auto', multiple_datasets=False, legend_bool=True, legend_pos='outside', save=False, image_format='png', dpi=300, image_save_path=None)
Plots deviation of cutoff
number of subtrees in original dataset and num_null
resamples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subtree |
string
|
Type of subtree. |
required |
df_true_melt_subset |
DataFrame
|
DataFrame with cutoff number of most significant subtrees for plotting.
Sorted by z-score from most over-represented to most under-represented.
Output from |
required |
df_null_zscores_i_c_melt_subset |
DataFrame
|
Melted DataFrame with null z-score for |
required |
df_null_zscores_i_c_melt_100resamples_subset |
DataFrame
|
Melted DataFrame with null z-score for |
required |
cell_color_dict |
dict
|
Keys are cell fates, values are colors. |
required |
fdr_type |
string
|
Use the Benjamini and Hochberg FDR correction if 'fdr_bh', use Benjamini and Hochberg FDR correction with two stage linear step-up procedure if 'fdr_tsbh'. Uses 'fdr_tsbh' by default. |
'fdr_tsbh'
|
cutoff |
string or NoneType or int
|
Take |
'auto'
|
title |
string
|
Title to use for plot. If not provided explicitly, will be automatically determined to read |
'auto'
|
multiple_datasets |
bool
|
Modify x-axis label depending if single or multiple datasets were used. |
False
|
legend_bool |
bool
|
Include legend in plot. |
True
|
legend_pos |
string
|
Position of legend (outside or inside). |
'outside'
|
save |
bool
|
If True, save figure as file. |
False
|
image |
format (string
|
Format of image file to be saved (png or svg). |
required |
dpi |
int
|
Resolution of saved image file. |
300
|
image_save_path |
string
|
Path to saved image file. |
None
|
Source code in linmo/plot.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
|
plot_frequency(subtree, df_true_melt_subset, df_melt_subset, df_melt_100resamples_subset, cell_color_dict, use_expected=True, fdr_type='fdr_tsbh', cutoff='auto', title='auto', multiple_datasets=False, legend_bool=True, legend_pos='outside', save=False, image_format='png', dpi=300, image_save_path=None)
Plots frequency of cutoff
number of subtrees in original dataset and all resamples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subtree |
string
|
Type of subtree. |
required |
df_true_melt_subset |
DataFrame
|
DataFrame with |
required |
df_melt_subset |
DataFrame
|
Melted DataFrame with observed count for |
required |
df_melt_100resamples_subset |
DataFrame
|
Melted DataFrame with observed count for |
required |
cell_color_dict |
dict
|
Keys are cell fates, values are colors. |
required |
use_expected |
Boolean
|
Use expected count in DataFrame. |
True
|
fdr_type |
string
|
Use the Benjamini and Hochberg FDR correction if 'fdr_bh', use Benjamini and Hochberg FDR correction with two stage linear step-up procedure if 'fdr_tsbh'. Uses 'fdr_tsbh' by default. |
'fdr_tsbh'
|
cutoff |
string or NoneType or int
|
Take |
'auto'
|
title |
string
|
Title to use for plot. If not provided explicitly, will be automatically determined to read |
'auto'
|
multiple_datasets |
bool
|
Modify x-axis label depending if single or multiple datasets were used. |
False
|
legend_bool |
bool
|
Include legend in plot. |
True
|
legend_pos |
string
|
Position of legend (outside or inside). |
'outside'
|
save |
bool
|
If True, save figure as file. |
False
|
image |
format (string
|
Format of image file to be saved (png or svg). |
required |
dpi |
int
|
Resolution of saved image file. |
300
|
image_save_path |
string
|
Path to saved image file. |
None
|
Source code in linmo/plot.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
|
linmo.simulate
Provides functions for simulating lineage trees.
This module contains the following functions:
- simulate_tree
- Simulate tree based on provided transition matrix and progenitor/cell type labels.
simulate_tree(transition_matrix, starting_progenitor, labels)
Simulate tree based on provided transition matrix and progenitor/cell type labels. Progenitors are represented by lowercase letters, cell types are represented by uppercase letters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transition_matrix |
array
|
matrix where rows represent original state, column represents state to transition into. Rows should sum to 1 for progenitors. |
required |
starting_progenitor |
string
|
string with starting progenitor |
required |
labels |
string
|
string with progenitor/cell type labels that correspond to the rows of the provided transition matrix. |
required |
Returns:
Name | Type | Description |
---|---|---|
tree_input |
string
|
new tree in NEWICK format after simulated division until no progenitor cells remaining. |