├── LICENSE
├── README.md
├── geomx
├── B Cells.tsv
├── CD8+ T-Cells.tsv
├── Endothelial Cells.tsv
├── Macrophage_monocyte.tsv
├── Th.tsv
├── Treg.tsv
├── Tumor Cells.tsv
└── tumor_mingle_timepoint0.tsv
├── img
├── Fig2a.pdf
├── cutoffs.png
├── fig2b.png
├── fig2b.pptx
├── placeholder
└── spacia_logo.PNG
├── singularity_build.def
├── spacia.R
├── spacia.py
├── spacia
├── Automate_Cutoff_Spacia.R
├── BetaB2MCMCPlots.R
├── Fun_MICProB_C2Cinter.cpp
├── Fun_construct_bags.cpp
├── MICProB_MIL_C2Cinter.R
├── MIL_wrapper.R
├── Workflow_Helpers.py
└── spacia_job.R
├── test.py
├── test
└── input
│ ├── counts.txt
│ ├── gene_cutoffs_A-B.txt
│ └── spacia_metadata.txt
└── tutorials
├── SpaciaR_Example_Workflow.ipynb
├── demo.ipynb
├── demo_data
├── base_10_pathways
│ ├── betas.csv
│ ├── simulation_metadata.txt
│ └── spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100
│ │ ├── spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_FDRs.txt
│ │ ├── spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_PSRF.txt
│ │ ├── spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_b.txt
│ │ ├── spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_beta.txt
│ │ ├── spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_log.txt
│ │ ├── spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_pip.txt
│ │ └── spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_pip_recal.txt
└── noise_level_0.5_5_pathways
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_FDRs.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_PSRF.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_autocorr.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_b.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_beta.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_density.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_log.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_pip.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_pip_recal.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_psrf.pdf
│ └── spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_trace.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_FDRs.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_PSRF.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_autocorr.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_b.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_beta.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_density.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_log.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_pip.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_pip_recal.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_psrf.pdf
│ └── spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_trace.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_FDRs.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_PSRF.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_autocorr.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_b.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_beta.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_density.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_log.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_pip.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_pip_recal.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_psrf.pdf
│ └── spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_trace.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_FDRs.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_PSRF.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_autocorr.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_b.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_beta.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_density.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_log.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_pip.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_pip_recal.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_psrf.pdf
│ └── spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_trace.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_FDRs.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_PSRF.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_autocorr.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_b.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_beta.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_density.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_log.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_pip.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_pip_recal.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_psrf.pdf
│ └── spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_trace.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_FDRs.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_PSRF.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_autocorr.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_b.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_beta.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_density.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_log.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_pip.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_pip_recal.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_psrf.pdf
│ └── spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_trace.pdf
│ └── spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_FDRs.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_PSRF.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_autocorr.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_b.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_beta.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_density.pdf
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_log.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_pip.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_pip_recal.txt
│ ├── spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_psrf.pdf
│ └── spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_trace.pdf
├── python_interface_tutorial.md
└── r_interface_tutorial.md
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2022, Yunguan Wang
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | 2. Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | 3. Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
: Inferring Cell-cell Interaction from Spatial Transcriptomics Data
2 |
3 | ## Introduction
4 | Multicellular organisms heavily rely on cell-cell interactions to effectively coordinate and regulate various biological processes, ensuring the normal functioning of the organism. Spacia models and evaluates cell-cell interactions from spatial transcriptomic data (SRT). This model uses cell-cell proximity as a constraint and prioritizes cell-cell interactions that cause a downstream change in the cells. Spacia employs a Bayesian multi-instance learning (MIL) framework to assess intercellular communication between cells and their neighbors.
5 |
6 | ## Graphical abstract
7 |
8 |
9 |
10 | # Python interface
11 |
12 | ## Installation
13 | This project requires R and Python with the following dependencies:
14 |
15 | ### Dependency
16 | - R: R>=4.0.5
17 | - Python: Python>=3.8
18 |
19 | #### OS requirement:
20 | Spacia is developed and tested in a Linux environment with x86-64 architecture (Red Hat Enterprise Linux Server 7.9).
21 |
22 | #### R Packages:
23 | - coda==0.19-4
24 | - ggmcmc==1.5.1.1
25 | - Rcpp==1.0.9
26 | - RcppArmadillo==0.11.2.3.1
27 | - rjson==0.2.21
28 | - data.table==1.14.8
29 |
30 | #### Python Packages:
31 | - matplotlib==3.7.2
32 | - pandas==2.0.3
33 | - scipy==1.10.1
34 | - scikit-learn==1.3.0
35 | - numpy ==1.24.3
36 |
37 | We strongly recommend using conda to manage the installation of all dependencies. To set up the environment and install specific versions, run the following commands:
38 |
39 | ```bash
40 | conda create --name spacia
41 | conda activate spacia
42 | # conda config --add channels conda-forge # If you do not have this channel added previously
43 | conda install python=3.8 pandas=2.0.3 scikit-learn=1.3.0 numpy=1.24.3 scipy=1.10.1 matplotlib=3.7.2
44 |
45 | # If you are having trouble setting up the python env, try removing the version restrictions for the packages.
46 | conda install python=3.8 pandas scikit-learn numpy scipy matplotlib
47 | ```
48 |
49 | Install the R packages:
50 | ```
51 | R
52 | install.packages(c('coda', 'ggmcmc', 'Rcpp', 'RcppArmadillo', 'rjson', 'data.table'))
53 | ```
54 |
55 | Then, download this repo.
56 | ```
57 | git clone [repo_path]
58 | ```
59 |
60 | The total installation time is around 10 minutes. If an error occurs, please upgrade pip and try again.
61 |
62 | **Note**: If you are on a macOS and do not have the Xcode Command Line Tools installed, please do so by running `xcode-select --install` in terminal.
63 |
64 | ## Test installation
65 | Test Spacia using a simple test script by:
66 |
67 | ```python test.py```
68 |
69 | The output should look like this
70 |
71 | ```
72 | Testing Spacia with a single gene as response feature and simple aggregation
73 | Test Succeeded.
74 | Testing Spacia with multiple genes as response feature and no agg mode
75 | Test Succeeded.
76 | Testing Spacia with multiple genes as response feature and pca agg mode
77 | Test Succeeded.
78 | ```
79 |
80 | **Note**: You may get some warning messages from the Rcpp package, but this does not affect the performance of the software.
81 |
82 | ### About the test data
83 |
84 | The test data, available in this repo at `test/input`, is a randomly generated dataset for the purpose of validating the installation only, and thus there is no interpretation associated with the test results.
85 |
86 | The test data contains a gene expression matrix (`counts.txt`) and a cell metadata table (`spacia_metadata.txt`).
87 |
88 | The gene expression data is a 2,844 x 100 cell-by-gene matrix, where the first column is cell names, and the first row is the gene names.
89 | | | gene1 | gene2 | gene3 | gene4 | gene5 |
90 | | --- | ---| --- | ---| --- | ---|
91 | | cell_0 | 1.06 | 2.14 | 1.36 | 0.94 | 1.52 |
92 | | cell_1 | 0.97 | 2.42 | 1.43 | 1.21 | 1.17 |
93 | | cell_2 | 0.76 | 2.16 | 1.07 | 1.46 | 1.47 |
94 | | cell_3 | 0.82 | 2.01 | 1.25 | 1.18 | 2.13 |
95 |
96 | The cell metadata contains spatial coordinates of each cell, as well as its cell type assignment.
97 |
98 | | |X|Y|cell_type
99 | | --- | ---| --- | ---|
100 | cell_0|0|0|A
101 | cell_1|0|1|B
102 | cell_2|0|2|B
103 | cell_3|0|3|A
104 |
105 | ## Singularity Container
106 | A `singularity` container is built and tested in `singularity>=4.1`. It can be downloaded by running
107 |
108 | ```
109 | cd [path/to/spacia]
110 | singularity pull --arch amd64 library://yunguanwang/spacia/spacia:latest
111 | ```
112 |
113 | To test the singularity container, simply run the following commands:
114 | ```
115 | cd [path/to/spacia]
116 | singularity exec python test.py
117 | ```
118 | A successful spacia run through the singularity container should produce the same results as seen in the previous **Test** section.
119 |
120 | Running spacia.py using singularity will require mapping the local folder to the container. For example, if the input data for `spacia.py` is in the `/data/input` folder, and you want to map it to the `/wd` folder for the singularity container to use, run the following command:
121 | ```
122 | singularity exec --bind /data/input:/wd python spacia.py /wd/spacia_inputs_1.txt /wd/spacia_inputs_2.txt [additional_arguments]
123 | ```
124 |
125 | ## Usage
126 |
127 | ### Definition of terms used in Spacia
128 | **Interaction**: Relationship between a pair **interactants** that potentially leads to downstream signalling events in cells. The **interactant** can be a gene or a geneset.
129 |
130 | **Signal**: The **interactant** in the **interaction** that is causing downstream signaling events.
131 |
132 | **Response**: The **interactant** in the **interaction** whose expression is changed as the result of activities from **Signal**.
133 |
134 | **Sender**: A cell where the **Signal** is expressed.
135 |
136 | **Receiver**: A cell where the **Response** is expressed.
137 |
138 | **Neighborhood**: A regions centering around each **Receivers** that contains **Senders** of interest.
139 |
140 | ### Quick start
141 | Once the input data have been processed into the supported format, the full Spacia workflow can be run by calling the `spacia.py` script. It evaluates interactions within the context of cell neighborhoods, where the ‘**receiver**’ cells are the cells of interest, and the cells from the neighborhood are referred to as "**sender**" cells. The **interactant** expressed in the receiver cells, through which the interactions are to be studied, are referred to as "**Response**", while the **interactant** expressed in the sender cells that potentially influence the responder genes are called signal “**Signal**".
142 |
143 | ```
144 | python [path/to/spacia.py] counts.txt cell_metadata.txt -rc celltype1 sc celltype2 -rf gene1 sf gene2
145 | ```
146 |
147 | Here, `counts.txt` is a cell-by-gene matrix in TX format. We expect the data to be normalized as log1p(cpm).
148 |
149 | `cell_metadata.txt` is a cell_by_metadata matrix in txt format in TXT format. Must contains `X` and `Y` columns for coordinates, and a `cell_type` column, referring to the group designation of cells, is needed if '-rc' or '-sc' parameters are given.
150 |
151 | `-rc` and `-sc` refer to **receiver** cells and **sender** cells, respectively.
152 |
153 | `-rf` and `-sf` refer to **Response** and **Signal** features. Here they are in form of single genes. Spacia can also take pathways in the format of a list of genes as input features.
154 |
155 |
156 | ### Processing **interactant** expression
157 | **Spacia employs several different workflows to calculate **interactant** expression in cells, aiming to handle use cases of different purposes. The behavior is controlled largely by the `--receiver_features` and `--sender_features` parameters, and a few others to a lesser extent.**
158 | * Spacia evaluates **interactions** in the contexts of **receiver** and **sender** cells. Instructions regarding this can be passed to `--receiver_cluster` or `--sender_cluster`, if cluster labels are available in the cell_by_metadata matrix. Alternatively, the cell ids of both **receiver** and **sender** cells can be passed using a csv file by passing the file name to `--cellid_file`. The cell id csv file has two columns with no headers corresponding to **receiver** and **sender** cells, respectively.
159 | * When the **interactant** is a single gene, Spacia can try to mitigate noises associated with gene expression in SRT data by considering the expression of highly correlated genes (by absolute Pearson correlation values). This behavior can be turned off by passing the `--corr_agg` keyword. The number of highly correlated genes to consider can be changed by passing the desired number to the `--num_corr_genes` keyword. The new expression value considering these correlated genes can be calculated as the weighted average of their expression, whereas the weights are the Pearson correlation coefficients with the gene of interest. In cases where only the positively correlated genes should be considered, Spacia will only include the top positively correlated genes to calculate the expression of the **interactant**. This behavior can be set by passing `--corr_agg_method simple`.
160 | * When the **interactant** contains several genes, Spacia will no longer use correlation based aggregation, instead, the average of the inputs genes will be calculated and used as the expression of the interactant.
161 | The list of genes can be passed as a string separated by "|", e.g., 'CD3E|CD4|CD8A'. It can be also passed by csv files, with each gene list as a separate row, where the first element is the name of the gene list. These parameters should be passed to `--receiver_features` or `--sender_features`.
162 | * Spacia can also be run in two unsupervised modes where the **interactant** is not provided. In the first unsupervised mode, Spacia will transform the SRT data using the first 20 principal components, and use the transformed dimensions as **interactants**. ****This mode is not recommended for response genes, as the interactions predicted in this way are difficult to interpret.**** This mode can be set by passing `pca` to `--receiver_features` or `--sender_features`. In the second unsupervised mode, Spacia will cluster the genes in the SRT data using hierarchical clustering and use the expression value of each cluster centroid as the **interactions**. This mode can be set by not passing any parameters to `--receiver_features` or `--sender_features`.
163 |
164 | #### A summary of important parameters mentioned above
165 | `--receiver_features` and `--sender_features`: Controls the **interactants** in Spacia, can be a single gene, a set of genes separated by "|", `pca` for the first unsupervised mode, or left blank for the second unsupervised mode.
166 |
167 | `--receiver_cluster` and `--sender_cluster`, `--cellid_file`: Controls the cellular contexts of **interactants** in Spacia. `--receiver_cluster` and `--sender_cluster` must be cluster names present in metadata, if these are left blank, `--cellid_file` must be provided.
168 |
169 | `--corr_agg`, `--num_corr_genes` and `--corr_agg_method`: Determines how the gene expression is aggregated.
170 |
171 | #### List of other important parameters
172 | `--dist_cutoff` or `--n_neighbors`: Determines the radius of the neighborhood around each receiver cell. Can be passed as an exact number to `--dist_cutoff` or estimated based on the required number of neighbors given by `--n_neighbors`.
173 |
174 | `--bag_size`: The minimal size of each bag in the MIC model, i.e., the minimal number of **sender** cells within each **receiver** cell's neighborhood.
175 |
176 | `--number_bags`: The number of bags used in the MIL model.
177 |
178 | `--mcmc_params`: Advanced hyperparameters for the MIL model.
179 |
180 | `--output_path`: Output folder for Spacia.
181 |
182 | #### Output file format
183 | The primary output of Spacia is a set of files containing a high level summary of the final results. These files are `B_and_FDR.csv`, `Pathway_betas.csv`, and `Interactions.csv`.
184 |
185 | `B_and_FDR.csv` contains the **b** values of each response gene/pathway (first column) and the associated significance information.
186 |
187 | `Pathway_betas.csv` contains the **beta** values representing the interaction between each response gene/pathway (first column) and signal gene/pathway (second columns).
188 |
189 | `Interactions.csv` contains the primary instance scores of all receivers in each receiver-sender cell pair (second and third column) for each response-signal interaction (first column).
190 |
191 | ##### Advanced outputs
192 |
193 | Spacia also saves the intermediate results in each `Response_name` folder, which are summarized into the primary output. These files include:
194 |
195 | Diagnostic plots in pdf formats reporting the behavior of each MCMC chains.
196 |
197 | Values of **b** and **beta** as calculated during each MCMC iteration/chain. `[Response_name]_[b/beta].txt`
198 |
199 | Primary instance scores between each receiver and sender, in long format. To decode this, please refer to the `model_input/metadata.txt` file, and flatten the `Sender_cells` column. You can do this in `Pandas` using the `str.split` and `explode` functions.
200 |
201 |
202 | # R interface
203 |
204 | For users who want to directly access the core of Spacia and perform more flexible analyses (we strongly encourage you to do so) , we provide an R interface that showcases the few key steps. Please remember to customize the workflow according to your needs/datasets. This interface showcases our suggested pipeline of data processing, and the codes should be self-explanatory. Our analysis codes of the prostate Merscope data (Fig. 2) are derived based on this workflow. The major pre-processing, inference, and post-processing steps shown in this R interface are overall consistent with those in `spacia.py`. We expect different SRT technologies to generate data in different formats and vary in quality. For maximum performance, we suggest that users perform data pre-processing and thorough quality filtering on their own, then massage the filtered data to the right format to feed into the core of Spacia. Please checkout our [**workflow for spatial gene signature analysis python notebook**](tutorials/SpaciaR_Example_Workflow.ipynb) to run your own analysis and generate plots.
205 |
206 | ## Installation
207 |
208 | In addition to the R packages for `spacia.py`, the following are needed to be installed:
209 |
210 | Installation commands:
211 | ```
212 | R
213 | #core packages
214 | install.packages(c('coda', 'ggmcmc', 'Rcpp', 'RcppArmadillo', 'rjson', 'diptest', 'RcppProgress', 'jsonlite'))
215 |
216 | #R interface specific packages
217 | install.packages(c('optparse', 'filelock', 'ggplot2', 'patchwork', 'scales', 'gridExtra', 'dplyr', 'RColorBrewer'))
218 | ```
219 |
220 | ## Test installation
221 |
222 | We use the same example data under `test/input` to test the R interface. Note that the data and parameters used in the example below is only intended for a quick test and does not produce stable or usable output. For real data, users should use parameters closer to the default values, where possible, and expect higher resource usage and computation time.
223 |
224 | ```
225 | export dir=[path/to/Spacia]
226 | Rscript $dir/spacia.R \
227 | -x $dir/test/input/counts.txt \
228 | -m $dir/test/input/spacia_metadata.txt \
229 | -a $dir/spacia \
230 | -r B -s A -g gene2 \
231 | -q 0.252 -u 0.091 \
232 | -d 2 -l 5000 -w 2500 \
233 | -o $dir/test/r_test/
234 | ```
235 | Use `-h` or `--help` to see detailed descriptions of options and inputs.
236 |
237 | Outputs `Fibroblasts-Tumor_cells_ACKR3.RData`, `Fibroblasts-Tumor_cells_ACKR3_betas.csv`, and `Fibroblasts-Tumor_cells_ACKR3_pip.csv` should be generated under `[path/to/Spacia]/test/r_test/`.
238 |
239 | ### Determining cutoffs
240 | The R interface is updated to support automatic gene signature cutoffs for each receiving gene input, which determines appropriate bag labels from expression weighted by correlation. Simply omit the relevant options (`-q`, `-u`, and `-t`) and `spacia.R` will determine the cutoffs and generate the paramTable. You may also manually select the cutoffs by setting `--generateCutoffs` as False and find the subplot with a dip(bimodal distribution) with the most correlated genes, and record its correlation cutoff and the quantile cutoff where the dip is located.
241 |
242 | Different cutoffs must be used for different combinations of receiving cell and receiving gene, and we recommend finding new cutoffs for each sending cell type as well. The included [example](test/input/gene_cutoffs_A-B.txt) shows the format compatible with `spacia.R` and can be passed to `-t`. This is analogues to the automated process in `spacia.py` if `--response_exp_cutoff 'auto'` is used, but is more reliable.
243 |
244 | ### Outline for large scale runs
245 | Consider following these steps if running Spacia on a large scale (e.g. screen for all potential cell-to-cell communications in a MERSCOPE or CosMx dataset).
246 |
247 | #### (1) Format and pre-process data.
248 |
249 | We highly recommend users perform their own quality control and normalization. Spacia will perform rudimentary normalization if `-C` option is used, but will not perform any filtering. Cell types must be determined and present in the meta data csv, and cell names must be consistent between the inputs.
250 |
251 | #### (2) Determine the scope of the analysis.
252 |
253 | Due to costs in time and computation, we recommend users limit their analysis to cell types and genes of interest if possible. Note that `spacia.R` runs in the 'PCA' mode, thus its performance is not greatly affected by the number of genes in the input data and genes should not be removed to imporve performance. However, since each run consists of a combination of sending cell type, receiving cell type, and receiving gene, we recommend users at least limit the list of receiving genes to the most highly expressed genes in the receiving cells of interest in order to reduce the total number of Spacia jobs.
254 |
255 | #### (3) Determine receiving gene cutoffs.
256 |
257 | Run Spacia with a list of receiving genes as input for `-g`, with one output directory for each receiving cell type. We recommend organizing the output directory in the form of `mainOutputDir/receivingCellType/sendingCellType/`, although `spacia.R` will prefix output files with `sendingCellType-receivingCellType_receivingGene`, making it possible to use just one output directory. If the path passed to `-o` ends in `/`, it will be interpreted as a directory, otherwise it is considered a prefix. Though not optimal, it is acceptable to re-use cutoffs for interactions involving different sending cell types if they share the same receiving cell type. Determine and record the cutoffs for the desired receiving genes in seperate csv files for each receiving cell type as detailed in the `Determining cutoffs` section above.
258 |
259 | #### (4) Parallelization.
260 |
261 | Spacia jobs are independent of each other and can be run on different systems simultaneously. If a shared filesystem is available for output, users can simply run multiple instances of Spacia with the same output directory for each sending-receiving cell combination and leave `-g` blank, in which case all receiving genes in the corresponding csv entered for `-t` will be processed iteratively and lock files are used to avoid duplicate runs. Otherwise, manually divide the receiving genes for each cell type combination and provide these different lists as inputs for `-g` for seperate runs. After testing, we found that multiprocessing often results in longer overall run time for `spacia.R`, and we therefore did not include multiprocessing capability. We do not recommend running more than two `spacia.R` instances in parallel on one system, and systems with less than 20 physical CPU cores should only run jobs sequentially. From our experience, it’s better to scale Spacia runs using a large number of smaller systems, rather than on one single system with many cores. The relatively low memory usage of a given Spacia run facilitates this approach. We would also like to point out that competing tools such as COMMOT and SpatialDM do not offer the option to distribute the workload like Spacia. For datasets with large cell numbers (> 50k cells), this results in very long run times that cannot be accelerated, with runs potentially lasting days before throwing an error and failing.
262 |
263 | ### Contact Us
264 | If you have any suggestions/ideas for Spacia or are having issues trying to use it, please don't hesitate to reach out to us.
265 |
266 | Noah Chang, wooyong.chang@utsouthwestern.edu
267 |
268 | James Zhu, james.zhu@utsouthwestern.edu
269 |
270 | Yunguan Wang, yunguan.wang@cchmc.org
271 |
272 |
--------------------------------------------------------------------------------
/img/Fig2a.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/img/Fig2a.pdf
--------------------------------------------------------------------------------
/img/cutoffs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/img/cutoffs.png
--------------------------------------------------------------------------------
/img/fig2b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/img/fig2b.png
--------------------------------------------------------------------------------
/img/fig2b.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/img/fig2b.pptx
--------------------------------------------------------------------------------
/img/placeholder:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/img/placeholder
--------------------------------------------------------------------------------
/img/spacia_logo.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/img/spacia_logo.PNG
--------------------------------------------------------------------------------
/singularity_build.def:
--------------------------------------------------------------------------------
1 | BootStrap: docker
2 | From: ubuntu:20.04
3 |
4 |
5 | %environment
6 | # set up all essential environment variables
7 | export LC_ALL=C
8 | export PATH=/miniconda3/bin:/usr/local/condabin:/root/.cargo/bin:/opt:$PATH
9 | export PYTHONPATH=/miniconda3/lib/python3.8/:$PYTHONPATH
10 |
11 | # activate conda environment
12 | source activate base;
13 | conda activate;
14 |
15 | %apprun R
16 | exec R "${@}"
17 |
18 | %apprun Rscript
19 | exec Rscript "${@}"
20 |
21 | %runscript
22 | exec R "${@}"
23 |
24 | %post
25 | # Get dependencies
26 | apt-get update
27 | apt-get install -y --no-install-recommends locales
28 |
29 | # Configure default locale
30 | echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
31 | locale-gen en_US.utf8
32 | /usr/sbin/update-locale LANG=en_US.UTF-8
33 | export LC_ALL=en_US.UTF-8
34 | export LANG=en_US.UTF-8
35 |
36 | # Set timezone
37 |
38 | TZ=America/New_York && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
39 | apt-get -y update
40 | apt-get update && apt-get install -y build-essential wget curl software-properties-common dirmngr gfortran
41 |
42 | # download, install, and update miniconda3
43 | wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
44 | bash Miniconda3-latest-Linux-x86_64.sh -b -f -p /miniconda3/
45 | rm Miniconda3-latest-Linux-x86_64.sh
46 |
47 | # install dependencies via conda
48 | export PATH="/miniconda3/bin:$PATH"
49 | conda install -y python=3.8 pandas=2.0.3 scikit-learn=1.3.0 numpy=1.24.3 scipy=1.10.1 matplotlib=3.7.2
50 | conda clean -y --all
51 |
52 | # Install R
53 | wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | \
54 | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
55 | add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
56 | apt-get install -y --no-install-recommends r-base r-base-dev
57 |
58 | # Add a default CRAN mirror
59 | echo "options(repos = c(CRAN = 'https://cran.rstudio.com/'), download.file.method = 'libcurl')" >> /usr/lib/R/etc/Rprofile.site
60 | # Install R packages
61 | Rscript -e 'install.packages("coda")'
62 | Rscript -e 'install.packages("Rcpp")'
63 | Rscript -e 'install.packages("ggmcmc")'
64 | Rscript -e 'install.packages("RcppArmadillo")'
65 | Rscript -e 'install.packages("rjson")'
66 | Rscript -e 'install.packages("data.table")'
67 | # Add a directory for host R libraries
68 | mkdir -p /library
69 | echo "R_LIBS_SITE=/library:\${R_LIBS_SITE}" >> /usr/lib/R/etc/Renviron.site
70 |
71 | # Clean up
72 | rm -rf /var/lib/apt/lists/*
--------------------------------------------------------------------------------
/spacia/Automate_Cutoff_Spacia.R:
--------------------------------------------------------------------------------
1 | library(diptest)
2 | library(data.table)
3 | library(ggplot2)
4 | library(gridExtra)
5 | library(RColorBrewer)
6 |
7 | #' Find Exact Correlation Cutoffs for Target Gene Counts
8 | #'
9 | #' This function determines the exact correlation cutoffs that result in
10 | #' specific numbers of correlated genes. It uses a binary search algorithm
11 | #' to find precise cutoffs for gene counts ranging from 20 to 2.
12 | #'
13 | #' @param cors Numeric vector of correlation values.
14 | #'
15 | #' @return A data frame with two columns:
16 | #' \item{cor_cutoffs}{Numeric vector of correlation cutoffs}
17 | #' \item{num_cor_genes}{Integer vector of corresponding gene counts (20 to 2)}
18 | #'
19 | #' @details
20 | #' The function performs a binary search for each target gene count (20 to 2)
21 | #' to find the correlation cutoff that yields exactly that number of genes.
22 | #' If an exact match is not found, it returns the closest approximation.
23 | #'
24 | #' @examples
25 | #' set.seed(123)
26 | #' cors <- runif(1000, -1, 1)
27 | #' result <- findExactCorCutoffs(cors)
28 | #' print(result)
29 | #'
30 | #' @export
31 | findExactCorCutoffs <- function(cors) {
32 | # Define target gene counts (from 20 to 2)
33 | target_gene_counts <- 20:2
34 |
35 | # Initialize vector to store correlation cutoffs
36 | cor_cutoffs <- numeric(length(target_gene_counts))
37 |
38 | # Iterate through each target gene count
39 | for (i in seq_along(target_gene_counts)) {
40 | target <- target_gene_counts[i]
41 |
42 | # Binary search to find the exact cutoffs
43 | low <- 0
44 | high <- 1
45 |
46 | while (high - low > 1e-6) { # Precision threshold
47 | mid <- (low + high) / 2
48 | count <- sum(abs(cors) > mid)
49 |
50 | if (count > target) {
51 | low <- mid
52 | } else if (count < target) {
53 | high <- mid
54 | } else {
55 | cor_cutoffs[i] <- mid
56 | break
57 | }
58 | }
59 |
60 | # If we didn't find an exact match, use the closest approximation
61 | if (cor_cutoffs[i] == 0) {
62 | cor_cutoffs[i] <- (low + high) / 2
63 | }
64 | }
65 |
66 | # Create a data frame with results
67 | cor_df <- data.frame(
68 | cor_cutoffs = cor_cutoffs,
69 | num_cor_genes = target_gene_counts
70 | )
71 |
72 | return(cor_df)
73 | }
74 |
75 |
76 |
77 |
78 | #' Check for Bimodality and Find Midpoint
79 | #'
80 | #' This function analyzes a numeric vector to determine if its distribution
81 | #' is bimodal and, if so, calculates the midpoint between the two modes.
82 | #'
83 | #' @param signature A numeric vector representing the distribution to be analyzed.
84 | #' @param alpha Numeric. Significance level for Hartigan's dip test (default: 0.05).
85 | #' @param min_peak_ratio Numeric. Minimum ratio of the lower peak to the higher peak (default: 0.3).
86 | #' @param min_valley_ratio Numeric. Minimum ratio of valley depth to lower peak height (default: 0.5).
87 | #'
88 | #' @return A list with the following components:
89 | #' \item{is_bimodal}{Logical. TRUE if the distribution is determined to be bimodal, FALSE otherwise.}
90 | #' \item{midpoint}{Numeric. The x-value of the deepest valley between the two highest peaks if bimodal, NULL otherwise.}
91 | #' \item{dip_pvalue}{Numeric. P-value from Hartigan's dip test.}
92 | #' \item{peak_ratio}{Numeric. Ratio of the lower peak to the higher peak.}
93 | #' \item{valley_ratio}{Numeric. Ratio of valley depth to lower peak height.}
94 | #'
95 | #' @examples
96 | #' set.seed(123)
97 | #' bimodal_data <- c(rnorm(500, mean = -2), rnorm(500, mean = 2))
98 | #' result <- check_bimodality_and_midpoint(bimodal_data)
99 | #' print(result)
100 | #'
101 | #' @import diptest
102 | #' @importFrom stats density
103 | #'
104 | #' @export
105 | check_bimodality_and_midpoint <- function(signature, alpha = 0.05, min_peak_ratio = 0.05, min_valley_ratio = 0.1) {
106 | # Perform Hartigan's dip test, suppressing messages
107 | dip_result <- suppressMessages(diptest::dip.test(signature))
108 |
109 | # If dip test doesn't suggest multimodality, return early
110 | if (dip_result$p.value >= alpha) {
111 | return(list(is_bimodal = FALSE, midpoint = NULL))
112 | }
113 |
114 | # Estimate density
115 | density_result <- stats::density(signature)
116 |
117 | # Find peaks and valleys
118 | peaks <- findPeaks(density_result$y)
119 | valleys <- findValleys(density_result$y)
120 |
121 | if (length(peaks) >= 2) {
122 | # Get the two highest peaks
123 | top_two_peaks <- peaks[order(density_result$y[peaks], decreasing = TRUE)[1:2]]
124 | peak_heights <- density_result$y[top_two_peaks]
125 | peak_ratio <- min(peak_heights) / max(peak_heights)
126 |
127 | if (peak_ratio > min_peak_ratio) {
128 | # Find the deepest valley between the two highest peaks
129 | valley_between <- valleys[valleys > min(top_two_peaks) & valleys < max(top_two_peaks)]
130 |
131 | if (length(valley_between) > 0) {
132 | deepest_valley <- valley_between[which.min(density_result$y[valley_between])]
133 | valley_depth <- min(peak_heights) - density_result$y[deepest_valley]
134 | valley_ratio <- valley_depth / min(peak_heights)
135 |
136 | if (valley_ratio > min_valley_ratio) {
137 | midpoint <- density_result$x[deepest_valley]
138 | return(list(is_bimodal = TRUE,
139 | midpoint = midpoint,
140 | dip_pvalue = dip_result$p.value,
141 | peak_ratio = peak_ratio,
142 | valley_ratio = valley_ratio))
143 | }
144 | }
145 | }
146 | }
147 |
148 | return(list(is_bimodal = FALSE, midpoint = NULL))
149 | }
150 |
151 |
152 |
153 |
154 | #' Find Peaks in a Numeric Vector
155 | #'
156 | #' @param x Numeric vector
157 | #' @return Integer vector of peak indices
158 | #' @keywords internal
159 | findPeaks <- function(x) which(diff(sign(diff(x))) < 0) + 1
160 |
161 | #' Find Valleys in a Numeric Vector
162 | #'
163 | #' @param x Numeric vector
164 | #' @return Integer vector of valley indices
165 | #' @keywords internal
166 | findValleys <- function(x) which(diff(sign(diff(x))) > 0) + 1
167 |
168 |
169 |
170 |
171 | #' Plot Density Distribution with Midpoint
172 | #'
173 | #' This function creates a density plot of the signature distribution,
174 | #' highlighting the midpoint and providing relevant statistical information.
175 | #' It also saves the plot as a PDF file in a specified folder.
176 | #'
177 | #' @param signature Numeric vector. The signature values to plot.
178 | #' @param midpoint Numeric. The calculated midpoint to highlight on the plot.
179 | #' @param cor_cutoff Numeric. The correlation cutoff used in the analysis.
180 | #' @param quantile Numeric. The calculated quantile value.
181 | #' @param num_cor_genes Integer. The number of correlated genes used.
182 | #' @param is_bimodal Logical. Whether the distribution is bimodal.
183 | #' @param receiving_gene Character. The name of the receiving gene.
184 | #' @param save_folder Character. The folder path to save the PDF plot.
185 | #'
186 | #' @return A ggplot object of the density plot.
187 | #'
188 | #' @import ggplot2
189 | #' @importFrom grDevices pdf dev.off
190 | #'
191 | #' @examples
192 | #' # Assuming necessary variables are defined
193 | #' plot <- plot_density_with_midpoint(signature, midpoint, cor_cutoff, quantile,
194 | #' num_cor_genes, is_bimodal, "GENE1", "plots/")
195 | #' print(plot)
196 | #'
197 | #' @export
198 | plot_density_with_midpoint <- function(signature, midpoint, cor_cutoff, quantile,
199 | num_cor_genes, is_bimodal, receiving_gene,
200 | save_folder) {
201 | # Construct the plot title
202 | plot_title <- sprintf("Signature Distribution of %s (Cutoff: %.4f, Quantile: %.4f, Genes: %d)",
203 | receiving_gene, cor_cutoff, quantile, num_cor_genes)
204 |
205 | # Modify title if distribution is not bimodal
206 | if (!is_bimodal) {
207 | plot_title <- paste(plot_title, "(Non-bimodal, using median)")
208 | }
209 |
210 | # Create the ggplot object
211 | plot <- ggplot(data.frame(signature = signature), aes(x = signature)) +
212 | geom_density(fill = "lightblue", alpha = 0.7) +
213 | geom_vline(xintercept = midpoint, color = "red", linetype = "dashed", linewidth = 1) +
214 | labs(title = plot_title,
215 | x = "Signature Value",
216 | y = "Density") +
217 | theme_minimal() +
218 | annotate("text", x = midpoint, y = 0, label = sprintf("Midpoint: %.2f", midpoint),
219 | vjust = -0.5, hjust = -0.1, color = "red")
220 |
221 | # Save the plot as a PDF file
222 | pdf_file <- file.path(save_folder, paste0(receiving_gene,"_automated_cutoff", ".pdf"))
223 | pdf(pdf_file, width = 10, height = 7) # Adjust width and height as needed
224 | print(plot)
225 | dev.off()
226 |
227 | # Return the plot object
228 | return(plot)
229 | }
230 |
231 |
232 |
233 |
234 | #' Automated Cutoff Generator for Spacia's bag binarization
235 | #'
236 | #' This function automates the process of finding optimal correlation cutoffs
237 | #' and quantile cutoffs for Spacia R's receiving_gene binarization.
238 | #' It performs correlation analysis, searches for bimodal distributions,
239 | #' and generates visualizations of the results.
240 | #'
241 | #' @param receiving_gene Character. The name of the receiving gene to analyze.
242 | #' @param counts_receiver data.table. Contains gene expression counts.
243 | #' The first column should be sample IDs, and other columns should be gene counts.
244 | #' @param save_folder Character. The path to the folder where plots will be saved.
245 | #' @param exp_sender List. Bags created for each receiving cell (used in signature calculation).
246 | #' @param backup_num_cor_genes Integer. Number of correlated genes to use if no bimodal
247 | #' distribution is found. Should be between 2 and 20. Default is 10.
248 | #' @param alpha Numeric. Significance level for Hartigan's dip test. Default is 0.05.
249 | #' @param min_peak_ratio Numeric. Minimum ratio of the lower peak to the higher peak. Default is 0.05.
250 | #' @param min_valley_ratio Numeric. Minimum ratio of valley depth to lower peak height. Default is 0.1.
251 | #'
252 | #' @return A list containing the results of the analysis, including:
253 | #' \item{data}{A data frame with the following columns:
254 | #' \itemize{
255 | #' \item cor_cutoff: The optimal correlation cutoff found
256 | #' \item midpoint: The midpoint of the bimodal distribution or median
257 | #' \item quantile: The quantile corresponding to the midpoint
258 | #' \item num_cor_genes: The number of correlated genes at the cutoff
259 | #' \item is_bimodal: Logical indicating if a bimodal distribution was found
260 | #' }
261 | #' }
262 | #' \item{plot}{The ggplot object of the density plot}
263 | #'
264 | #' @import data.table
265 | #' @importFrom stats cor ecdf median
266 | #' @importFrom utils head
267 | #'
268 | #' @examples
269 | #' # Assuming necessary data and functions are loaded
270 | #' result <- AutomatedCutoffGenerator("GENE1", counts_data, "plots/", exp_sender_data)
271 | #' print(result$data)
272 | #' print(result$plot)
273 | #'
274 | #' @export
275 | AutomatedCutoffGenerator <- function(receiving_gene, counts_receiver, save_folder, exp_sender,
276 | backup_num_cor_genes = 10, alpha = 0.05,
277 | min_peak_ratio = 0.05, min_valley_ratio = 0.1) {
278 |
279 | # Input validation
280 | if (!is.character(receiving_gene) || length(receiving_gene) != 1) {
281 | stop("receiving_gene must be a single character string")
282 | }
283 | if (!data.table::is.data.table(counts_receiver)) {
284 | stop("counts_receiver must be a data.table")
285 | }
286 | if (!dir.exists(save_folder)) {
287 | dir.create(save_folder, recursive = TRUE, showWarnings = FALSE)
288 | }
289 | if (!receiving_gene %in% colnames(counts_receiver)) {
290 | stop("receiving_gene not found in counts_receiver")
291 | }
292 | if (!is.numeric(backup_num_cor_genes) || backup_num_cor_genes < 2 || backup_num_cor_genes > 20) {
293 | stop("backup_num_cor_genes must be an integer between 2 and 20")
294 | }
295 | if (!is.numeric(alpha) || alpha <= 0 || alpha >= 1) {
296 | stop("alpha must be a numeric value between 0 and 1")
297 | }
298 | if (!is.numeric(min_peak_ratio) || min_peak_ratio <= 0 || min_peak_ratio >= 1) {
299 | stop("min_peak_ratio must be a numeric value between 0 and 1")
300 | }
301 | if (!is.numeric(min_valley_ratio) || min_valley_ratio <= 0 || min_valley_ratio >= 1) {
302 | stop("min_valley_ratio must be a numeric value between 0 and 1")
303 | }
304 |
305 | # Calculate correlations
306 | cors <- cor(counts_receiver[[receiving_gene]],
307 | counts_receiver[, -1, with = FALSE], use = "pairwise.complete.obs")[1,]
308 |
309 | # Find exact correlation cutoffs
310 | cor_df <- findExactCorCutoffs(cors)
311 |
312 | result <- NULL
313 | backup_iteration <- NULL
314 | plot <- NULL
315 |
316 | for (i in 1:nrow(cor_df)) {
317 | cor_cutoff <- cor_df$cor_cutoffs[i]
318 | num_cor_genes <- cor_df$num_cor_genes[i]
319 |
320 | keep <- abs(cors) > cor_cutoff
321 | selected_genes <- names(cors)[keep]
322 |
323 | # Signature calculation
324 | signature <- counts_receiver[
325 | get(names(counts_receiver)[1]) %in% names(exp_sender),
326 | .SD,
327 | .SDcols = selected_genes
328 | ][, {
329 | result <- colMeans(t(as.matrix(.SD)) * cors[keep])
330 | .(signature = result)
331 | }]
332 |
333 | # Check bimodality and find midpoint with new parameters
334 | bimodal_check <- check_bimodality_and_midpoint(signature$signature, alpha, min_peak_ratio, min_valley_ratio)
335 |
336 | if (bimodal_check$is_bimodal) {
337 | midpoint <- bimodal_check$midpoint
338 | quantile_result <- ecdf(signature$signature)(midpoint)
339 |
340 | result <- data.frame(
341 | cor_cutoff = cor_cutoff,
342 | midpoint = midpoint,
343 | quantile = quantile_result,
344 | num_cor_genes = num_cor_genes,
345 | is_bimodal = TRUE
346 | )
347 |
348 | # Generate the density plot
349 | plot <- plot_density_with_midpoint(signature$signature,
350 | midpoint,
351 | cor_cutoff,
352 | quantile_result,
353 | num_cor_genes,
354 | TRUE,
355 | receiving_gene,
356 | save_folder)
357 |
358 | break # Exit the loop once we find a bimodal distribution
359 | }
360 |
361 | # Store the backup iteration data for potential use later
362 | if (num_cor_genes == backup_num_cor_genes) {
363 | backup_iteration <- list(
364 | signature = signature$signature,
365 | cor_cutoff = cor_cutoff,
366 | num_cor_genes = num_cor_genes
367 | )
368 | }
369 | }
370 |
371 | # If no bimodal distribution was found, use the backup cutoff and median
372 | if (is.null(result)) {
373 | if (is.null(backup_iteration)) {
374 | stop("No valid backup iteration found. Check your backup_num_cor_genes value.")
375 | }
376 |
377 | signature <- backup_iteration$signature
378 | cor_cutoff <- backup_iteration$cor_cutoff
379 | num_cor_genes <- backup_iteration$num_cor_genes
380 |
381 | midpoint <- median(signature)
382 | quantile_result <- 0.5 # by definition, the median is at the 0.5 quantile
383 |
384 | result <- data.frame(
385 | cor_cutoff = cor_cutoff,
386 | midpoint = midpoint,
387 | quantile = quantile_result,
388 | num_cor_genes = num_cor_genes,
389 | is_bimodal = FALSE
390 | )
391 |
392 | # Generate the density plot
393 | plot <- plot_density_with_midpoint(signature,
394 | midpoint,
395 | cor_cutoff,
396 | quantile_result,
397 | num_cor_genes,
398 | FALSE,
399 | receiving_gene,
400 | save_folder)
401 |
402 | cat(sprintf("No bimodal distribution found. Using backup cutoff for %s (num_cor_genes = %d) and median.\n",
403 | receiving_gene,
404 | backup_num_cor_genes))
405 | }
406 |
407 | # Return both the result data frame and the plot
408 | return(list(data = result, plot = plot))
409 | }
410 |
411 |
412 |
413 | #' Generate Plots for Multiple Correlation Cutoffs with Visible Quantile Labels
414 | #'
415 | #' This function generates density plots for gene signatures at different correlation cutoffs,
416 | #' allowing users to visualize the distribution and manually annotate suitable cutoffs.
417 | #' It includes clearly visible labeled quantile lines for easy reference.
418 | #'
419 | #' @param receiving_gene Character. The name of the receiving gene to analyze.
420 | #' @param counts_receiver data.table. Contains gene expression counts.
421 | #' The first column should be sample IDs, and other columns should be gene counts.
422 | #' @param save_folder Character. The path to the folder where plots will be saved.
423 | #' @param exp_sender List. Bags created for each receiving cell (used in signature calculation).
424 | #'
425 | #' @return A grob object containing the combined plot of all cutoffs.
426 | #'
427 | #' @import ggplot2
428 | #' @import gridExtra
429 | #' @import RColorBrewer
430 | #' @importFrom stats cor quantile
431 | #' @importFrom grDevices pdf dev.off
432 | CutoffPlotGenerator <- function(receiving_gene, counts_receiver, output_file, exp_sender) {
433 | # Input validation
434 | if (!is.character(receiving_gene) || length(receiving_gene) != 1) {
435 | stop("receiving_gene must be a single character string")
436 | }
437 | if (!data.table::is.data.table(counts_receiver)) {
438 | stop("counts_receiver must be a data.table")
439 | }
440 | if (!receiving_gene %in% colnames(counts_receiver)) {
441 | stop("receiving_gene not found in counts_receiver")
442 | }
443 |
444 | # Create output directory if it doesn't exist
445 | output_dir <- dirname(output_file)
446 | if (!dir.exists(output_dir)) {
447 | dir.create(output_dir, recursive = TRUE, showWarnings = FALSE)
448 | }
449 |
450 | # Calculate correlations
451 | cors <- cor(counts_receiver[[receiving_gene]],
452 | counts_receiver[, -1, with = FALSE], use = "pairwise.complete.obs")[1,]
453 |
454 | # Find exact correlation cutoffs
455 | cor_df <- findExactCorCutoffs(cors)
456 |
457 | # Define quantiles and colors
458 | quantiles <- seq(0.1, 0.9, by = 0.1)
459 | colors <- c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00",
460 | "#FFFF33", "#A65628", "#F781BF", "#999999")
461 |
462 | # Create a list to store all plots
463 | all_plots <- list()
464 |
465 | # Generate plots for each correlation cutoff
466 | for (i in 1:nrow(cor_df)) {
467 | cor_cutoff <- cor_df$cor_cutoffs[i]
468 | num_cor_genes <- cor_df$num_cor_genes[i]
469 |
470 | # Select genes based on correlation cutoff
471 | keep <- abs(cors) > cor_cutoff
472 | selected_genes <- names(cors)[keep]
473 |
474 | # Calculate signature
475 | signature <- counts_receiver[
476 | get(names(counts_receiver)[1]) %in% names(exp_sender),
477 | .SD,
478 | .SDcols = selected_genes
479 | ][, {
480 | result <- colMeans(t(as.matrix(.SD)) * cors[keep])
481 | .(signature = result)
482 | }]
483 |
484 | # Calculate quantile values
485 | quantile_values <- quantile(signature$signature, probs = quantiles)
486 |
487 | # Create the density plot
488 | plot <- ggplot(data.frame(signature = signature$signature), aes(x = signature)) +
489 | geom_density(fill = "lightblue", alpha = 0.7) +
490 | labs(title = sprintf("%s (Cutoff: %.4f, Genes: %d)",
491 | receiving_gene, cor_cutoff, num_cor_genes),
492 | x = "Signature Value",
493 | y = "Density") +
494 | theme_minimal() +
495 | theme(plot.title = element_text(size = 10),
496 | plot.margin = margin(t = 20, r = 5, b = 5, l = 5, unit = "pt"))
497 |
498 | # Get the y-range of the plot for label positioning
499 | y_range <- ggplot_build(plot)$layout$panel_scales_y[[1]]$range$range
500 |
501 | # Add quantile lines and labels to the plot
502 | for (j in 1:length(quantiles)) {
503 | plot <- plot +
504 | geom_vline(xintercept = quantile_values[j],
505 | color = colors[j],
506 | linetype = "dashed",
507 | linewidth = 0.5) +
508 | annotate("text",
509 | x = quantile_values[j],
510 | y = y_range[2] * 1.05,
511 | label = sprintf("%.1f", quantiles[j]),
512 | color = colors[j],
513 | angle = 90,
514 | size = 2.5,
515 | vjust = 0)
516 | }
517 |
518 | all_plots[[i]] <- plot
519 | }
520 |
521 | # Create a legend plot
522 | legend_data <- data.frame(
523 | x = 1:9,
524 | y = rep(1, 9),
525 | label = sprintf("%.1f", quantiles)
526 | )
527 | legend_plot <- ggplot(legend_data, aes(x = x, y = y, color = factor(x))) +
528 | geom_point() +
529 | scale_color_manual(values = colors, labels = legend_data$label) +
530 | theme_void() +
531 | theme(legend.position = "bottom") +
532 | labs(color = "Quantile") +
533 | guides(color = guide_legend(nrow = 3, byrow = TRUE))
534 |
535 | # Arrange plots in a grid
536 | n_plots <- length(all_plots)
537 | n_cols <- 5
538 | n_rows <- ceiling(n_plots / n_cols)
539 |
540 | grid_plots <- c(all_plots, list(legend_plot))
541 | if (length(grid_plots) < n_cols * n_rows) {
542 | grid_plots <- c(grid_plots, replicate(n_cols * n_rows - length(grid_plots), ggplot() + theme_void()))
543 | }
544 |
545 | # Combine plots
546 | combined_plot <- gridExtra::arrangeGrob(grobs = grid_plots, ncol = n_cols)
547 |
548 | # Save the combined plot as a PDF file
549 | ggsave(output_file, combined_plot, width = 20, height = 4 * n_rows, limitsize = FALSE)
550 | }
--------------------------------------------------------------------------------
/spacia/BetaB2MCMCPlots.R:
--------------------------------------------------------------------------------
1 | suppressPackageStartupMessages(library(coda))
2 | suppressPackageStartupMessages(library(ggmcmc))
3 |
4 | #' Create density, trace, autocorrelation, and PSRF plots
5 | #' for b and betas and return the ggmcmc::ggs() object, S
6 | #'
7 | #' @param beta_matrix matrix of the beta, where column names are populated
8 | #' @param b_matrix matrix of the b, where column names are populated
9 | #' @param nwarm number of warm up iterations (burn-in periods)
10 | #' @param ntotal total number of MCMC iterations
11 | #' @param nthin number used to thin and store posteriors
12 | #' @param nchain number of chains used in MCMC
13 | #' @param job_id string that specifies the job ID
14 | #' @param output_path string of output path
15 | #' @param ext extension used for the ggsave. Device to use.
16 | #' Can either be a device function (e.g. png), or one of
17 | #' "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png",
18 | #' "bmp", "svg" or "wmf" (windows only).
19 | #'
20 | #' @return ggmcmc::ggs() object
21 | #' @export
22 | #'
23 | #' @examples
24 | #' \dontrun{
25 | #'
26 | #' S <- BetaB2MCMCPlots(
27 | #' beta_matrix,
28 | #' b_matrix,
29 | #' 20000,
30 | #' 50000,
31 | #' 100,
32 | #' 2,
33 | #' "test",
34 | #' "./output_dir/",
35 | #' "pdf")
36 | #'
37 | #' }
38 | BetaB2MCMCPlots <- function(beta_matrix,
39 | b_matrix,
40 | nwarm,
41 | ntotal,
42 | nthin,
43 | nchain,
44 | job_id,
45 | output_path,
46 | ext
47 | ){
48 |
49 | # Create variables for the coda::mcmc object
50 | start = ntotal - nwarm + nthin
51 | end = ntotal
52 | niter = ntotal - nwarm
53 |
54 | # number of rows saved for each chain
55 | nsaved = 1 + (1 + floor((niter - 1) / nthin))
56 |
57 | # for mcmc.list() to take in
58 | list_of_mcmcs = vector(mode = "list", length = nchain)
59 |
60 | # Populate list_of_mcmcs by cbind b and beta
61 | for (chain in 1:nchain) {
62 | start_idx = ((chain-1)*nsaved+1) + 1 # We don't want iter 1
63 | end_idx = chain*nsaved
64 |
65 | data = cbind(
66 | beta_matrix[start_idx:end_idx,],
67 | b_matrix[start_idx:end_idx,2,drop=F]
68 | )
69 |
70 | list_of_mcmcs[[chain]] = mcmc(
71 | data = data,
72 | start = start,
73 | end = end,
74 | thin = nthin
75 | )
76 | }
77 |
78 | # Make mcmc.list obj
79 | mcmc_list_obj <- mcmc.list(list_of_mcmcs)
80 |
81 | # coda::mcmc.list to ggmcmc::ggs
82 | S = ggs(mcmc_list_obj)
83 |
84 | # Reorder levels
85 | nbeta = dim(beta_matrix)[2]
86 | S$Parameter <- factor(S$Parameter, levels = c(c("b.2"), paste("beta.", 1:nbeta, sep="")))
87 |
88 | # Calculate the appropriate width and height of the plot
89 | # When ncol(beta) = 50, (width, height) = (30, 30), (30, 30), (30, 90) cm works
90 | size = c(0, 0, 0)
91 | if (nbeta <= 4){ # one row
92 | size[1] = 3
93 | size[2] = round(nbeta/50 * 90)
94 | } else if (nbeta >= 66) { # max rows, ggsave supports max 127cm
95 | size[1] = 120
96 | size[2] = round(nbeta/50 * 90)
97 | } else { # calculate appropriate rows
98 | size[1] = round(nbeta/50 * 30)
99 | size[2] = round(nbeta/50 * 90)
100 | }
101 |
102 | size[3] = nchain * 15
103 |
104 | # Plot density, trace plot, and autocorrelation
105 | ggs_density(S)+ facet_wrap(~ Parameter, ncol = 5, scales = "free")
106 | ggsave(paste(output_path, job_id,'_density.', ext, sep=''),
107 | width = 30, height = size[1], units = "cm")
108 |
109 | ggs_traceplot(S) + facet_wrap(~ Parameter, ncol = 5, scales = "free")
110 | ggsave(paste(output_path, job_id,'_trace.', ext, sep=''),
111 | width = 30, height = size[1], units = "cm")
112 |
113 | ggs_autocorrelation(S)
114 | ggsave(paste(output_path, job_id,'_autocorr.', ext, sep=''),
115 | width = size[3], height = size[2], units = "cm")
116 |
117 |
118 | if ( nchain <= 1 ) {
119 | # We need multiple chains to assess PSRF
120 | warning("The number of chains is less than 2. Skipping PSRF plot.")
121 | } else {
122 | ggs_Rhat(S) + xlab("R_hat")
123 | ggsave(paste(output_path, job_id,'_psrf.', ext, sep=''),
124 | width = round(size[3]/3), height = round(size[2]/6), units = "cm")
125 | }
126 |
127 |
128 | # return the ggs object since we may want more plots
129 | return(S)
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/spacia/Fun_MICProB_C2Cinter.cpp:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------
2 | // Header (header)
3 | //--------------------------------------------------------------
4 | // [[Rcpp::depends(RcppArmadillo)]]
5 | #include
6 | #include
7 | using namespace Rcpp;
8 | using namespace arma;
9 |
10 |
11 | //--------------------------------------------------------------
12 | // Functions (Functions_cpp)
13 | //--------------------------------------------------------------
14 | arma::mat mvrnormArma(int n, arma::vec mu, arma::mat sigma) {
15 | int ncols = sigma.n_cols;
16 | mat Y = randn(n, ncols);
17 | return repmat(mu, 1, n).t() + Y * chol(sigma);
18 | }
19 |
20 | double log_sum_exp(const arma::vec& x) {
21 | unsigned int maxi = x.index_max();
22 | double maxv = x(maxi);
23 | if (!(maxv > -datum::inf)) {
24 | return -datum::inf;
25 | }
26 | double cumsum = 0.0;
27 | for (unsigned int i = 0; i < x.n_elem; i++) {
28 | if ((i != maxi) & (x(i) > -datum::inf)) {
29 | cumsum += exp(x(i) - maxv);
30 | }
31 | }
32 | return maxv + log1p(cumsum);
33 | }
34 |
35 |
36 | double c_rtexp_onesided(double a)
37 | {
38 | bool stop = false;
39 | double lambda = 0.5 * (a + sqrt(pow(a, 2) + 4));
40 | double z;
41 |
42 | while(!stop)
43 | {
44 | z = a - log(R::runif(0,1))/lambda;
45 | stop = (-2* log(R::runif(0,1)) > pow(z - lambda, 2));
46 | }
47 | return z;
48 | }
49 |
50 | // [[Rcpp::export]]
51 | arma::vec ctruncnorm(arma::vec mean,
52 | arma::vec sd,
53 | bool upper){
54 | int m = mean.size();
55 | vec p = normcdf(- mean / sd);
56 | vec res = zeros(m);
57 | if(upper){
58 | // right truncated
59 | p += (1.0 - p) % randu(m);
60 | for(int j = 0; j < m; j++) {
61 | if(- mean(j) / sd(j) > 3.48672170399){
62 | res(j) = sd(j) * c_rtexp_onesided(- mean(j) / sd(j)) + mean(j);
63 | } else{
64 | res(j) = R::qnorm(p(j), mean(j), sd(j), true, false);
65 | }
66 | }
67 | } else{
68 | // left truncated
69 | p = p % randu(m);
70 | for(int j = 0; j < m; j++) {
71 | if(- mean(j) / sd(j) < -3.48672170399){
72 | res(j) = - sd(j) * c_rtexp_onesided(mean(j) / sd(j)) + mean(j);
73 | } else{
74 | res(j) = R::qnorm(p(j), mean(j), sd(j), true, false);
75 | }
76 | }
77 | }
78 | return res;
79 | }
80 |
81 |
82 | // [[Rcpp::export]]
83 | Rcpp::List MICProB_1Gibbs_cpp(
84 | arma::mat Xb,
85 | arma::mat Xbeta,
86 | arma::vec y,
87 | arma::vec ninst,
88 |
89 | arma::vec hp_mu_beta,
90 | arma::vec hp_mu_b,
91 | arma::mat hp_Sig_beta,
92 | arma::mat hp_Sig_b,
93 |
94 | arma::vec beta,
95 | arma::vec b,
96 | arma::vec delta,
97 | arma::vec u,
98 | arma::vec z,
99 |
100 | arma::mat hp_Sig_beta_inv,
101 | arma::mat hp_Sig_b_inv,
102 | arma::mat V_b){
103 |
104 | int n = y.size(), db = Xb.n_cols,dbeta = Xbeta.n_cols;
105 |
106 | // set X_delta, mu_z
107 | mat X_delta = zeros(n, dbeta);
108 | vec mu_z = zeros(n);
109 | int pos = 0;
110 | for(int i = 0; i < n; i++){
111 | if(accu(delta.subvec(pos, pos + ninst[i] - 1)) != 0){
112 | X_delta.row(i) = sum(Xbeta.rows(pos + find(delta.subvec(pos, pos + ninst[i] - 1) == 1)),
113 | 0); // column sum
114 | }
115 | pos += ninst[i];
116 | }
117 | mu_z = beta(0) + X_delta * beta.tail(dbeta);
118 |
119 | // Rcout << "mu_z=\n" << mu_z << "\n";
120 |
121 | // update z
122 | colvec one_colvec = ones(n);
123 | //// y == 1
124 | uvec idx = find(y == 1);
125 | z(idx) = ctruncnorm(mu_z(idx), one_colvec(idx), true);
126 | //// y == 0
127 | idx = find(y == 0);
128 | z(idx) = ctruncnorm(mu_z(idx), one_colvec(idx), false);
129 | // z[y==1]<-rtruncnorm(sum(y==1),mean=mu_z[y==1],sd=1,a=0,b=Inf)
130 | // z[y==0]<-rtruncnorm(sum(y==0),mean=mu_z[y==0],sd=1,a=-Inf,b=0)
131 |
132 |
133 | // update beta
134 | mat X1_delta = join_rows(one_colvec, X_delta);
135 | // X1_delta<-cbind(1,X_delta)
136 | mat V_beta = inv_sympd(hp_Sig_beta_inv + X1_delta.t() * X1_delta);
137 | vec m_beta = V_beta * (hp_Sig_beta_inv * hp_mu_beta + X1_delta.t() * z);
138 | beta = m_beta + (randn(1, dbeta + 1) * chol(V_beta)).t();
139 |
140 | // update delta
141 | vec mu_u = b(0) + Xb * b.tail(db);
142 | vec probit_prob = normcdf(mu_u);
143 |
144 | // Rcout << "mu_u=\n" << mu_u << "\n";
145 | pos = 0;
146 | double A, B;
147 | for(int i = 0; i < n; i++){
148 | mat X_j = Xbeta.rows(pos, pos + ninst[i] - 1);
149 | vec delta_j = delta.subvec(pos, pos + ninst[i] - 1);
150 | for(int j = 0; j < ninst[i]; j++){
151 | double tmp = z(i) - beta(0) -
152 | accu(X_j.rows(find(delta_j == 1)) * beta.tail(dbeta)) +
153 | delta_j(j) * dot(X_j.row(j), beta.tail(dbeta));
154 |
155 | A = exp(-0.5 * pow(tmp - dot(X_j.row(j), beta.tail(dbeta)), 2.0));
156 | B = exp(-0.5 * pow(tmp, 2.0));
157 |
158 | double prim_prob = (A * probit_prob(pos + j)) /
159 | (A * probit_prob(pos + j) + B * (1 - probit_prob(pos + j)));
160 |
161 | if(std::isnan(prim_prob)){
162 | prim_prob = 0;
163 | }
164 | // Rcout << "prim_prob=\n" << prim_prob << "\n";
165 | if(conv_to::from(randu(1)) < prim_prob){
166 | delta(pos + j) = 1;
167 | } else{
168 | delta(pos + j) = 0;
169 | }
170 | }
171 | pos += ninst[i];
172 | }
173 |
174 | // update u
175 | //// delta == 1
176 |
177 | vec one_colvec2 = ones(Xb.n_rows);
178 | uvec idx_delta1 = find(delta == 1);
179 | u(idx_delta1) = ctruncnorm(mu_u(idx_delta1), one_colvec2(idx_delta1), true);
180 | //// delta == 0
181 | uvec idx_delta2 = find(delta == 0);
182 | u(idx_delta2) = ctruncnorm(mu_u(idx_delta2), one_colvec2(idx_delta2), false);
183 | // u [delta==1]<-rtruncnorm(sum(delta==1),mean=mu_u[delta==1],sd=1,a=0,b=Inf);
184 | // u[delta==0]<-rtruncnorm(sum(delta==0),mean=mu_u[delta==0],sd=1,a=-Inf,b=0)
185 |
186 | // // update u
187 | // //// delta == 1
188 | // one_colvec = ones(X.n_rows);
189 | // uvec idx_delta1 = find(delta == 1);
190 | // u(idx) = ctruncnorm(mu_u(idx), one_colvec(idx), true);
191 | // //// delta == 0
192 | // idx = find(delta == 0);
193 | // u(idx) = ctruncnorm(mu_u(idx), one_colvec(idx), false);
194 | // // u [delta==1]<-rtruncnorm(sum(delta==1),mean=mu_u[delta==1],sd=1,a=0,b=Inf);
195 | // // u[delta==0]<-rtruncnorm(sum(delta==0),mean=mu_u[delta==0],sd=1,a=-Inf,b=0)
196 |
197 | // update b
198 | // one_colvec = ones(X.n_rows);
199 | vec m_b = V_b * (hp_Sig_b_inv * hp_mu_b + join_rows(one_colvec2, Xb).t() * u);
200 | b = m_b + (randn(1, db + 1) * chol(V_b)).t();
201 | // Rcout << "here3\n";
202 |
203 | return List::create(
204 | Named("beta") = beta,
205 | Named("b") = b,
206 | Named("delta") = delta,
207 | Named("u") = u,
208 | Named("z") = z
209 | );
210 | }
211 |
--------------------------------------------------------------------------------
/spacia/Fun_construct_bags.cpp:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------
2 | // Header (header)
3 | //--------------------------------------------------------------
4 | // [[Rcpp::depends(RcppArmadillo)]]
5 | // [[Rcpp::depends(RcppProgress)]]
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | using namespace Rcpp;
13 |
14 | //--------------------------------------------------------------
15 | // Functions (Functions_cpp)
16 | //--------------------------------------------------------------
17 | // [[Rcpp::export]]
18 | List construct_bags(NumericMatrix xy_receiver, NumericMatrix xy_sender, CharacterVector cell_ids,
19 | double dist_cutoff2, int min_instance, int subSample) {
20 | int n_receiver = xy_receiver.nrow();
21 | int n_sender = xy_sender.nrow();
22 | List pos_sender;
23 | List exp_sender;
24 | CharacterVector pos_names;
25 | CharacterVector exp_names;
26 |
27 | // Determine the target number of bags
28 | int target_bags = (subSample > 0 && subSample < n_receiver) ? subSample : n_receiver;
29 |
30 | // Warning if subSample is greater than n_receiver
31 | if (subSample > n_receiver) {
32 | Rcpp::warning("subSample (%d) is greater than the number of receivers (%d). Using all receivers.", subSample, n_receiver);
33 | }
34 |
35 | // Create a randomly shuffled index vector
36 | std::vector indices(n_receiver);
37 | for (int i = 0; i < n_receiver; ++i) indices[i] = i;
38 | std::random_shuffle(indices.begin(), indices.end());
39 |
40 | Rcout << "Attempting to construct up to " << target_bags << " bags.\n";
41 |
42 | // Setup progress bar
43 | Progress p(n_receiver, true);
44 |
45 | int bags_constructed = 0;
46 | int receivers_checked = 0;
47 |
48 | while (bags_constructed < target_bags && receivers_checked < n_receiver) {
49 | // Check for user interrupt and update progress
50 | if (Progress::check_abort()) {
51 | throw Rcpp::exception("User interrupted the bag construction process.");
52 | }
53 | p.increment();
54 |
55 | int i = indices[receivers_checked];
56 | receivers_checked++;
57 |
58 | LogicalVector keep(n_sender);
59 | NumericVector dists(n_sender);
60 | for (int j = 0; j < n_sender; ++j) {
61 | double dist = pow(xy_receiver(i, 0) - xy_sender(j, 0), 2) +
62 | pow(xy_receiver(i, 1) - xy_sender(j, 1), 2);
63 | keep[j] = dist < dist_cutoff2;
64 | dists[j] = dist;
65 | }
66 |
67 | if (sum(keep) < min_instance) continue; // Skip if there aren't enough instances
68 |
69 | NumericVector valid_dists = sqrt(dists[keep]); // Only compute sqrt for valid distances
70 | pos_sender.push_back(log(valid_dists)); // Store the logarithm of valid distances
71 | exp_sender.push_back(keep); // Store the indices of valid senders
72 | pos_names.push_back(cell_ids[i]); // Assign cell IDs
73 | exp_names.push_back(cell_ids[i]);
74 |
75 | bags_constructed++;
76 | }
77 |
78 | // Setting names to the lists after the loop
79 | pos_sender.attr("names") = pos_names;
80 | exp_sender.attr("names") = exp_names;
81 |
82 | // Notify the user about the number of bags constructed and receivers checked
83 | Rcout << "Successfully constructed " << bags_constructed << " bags.\n";
84 | Rcout << "Checked " << receivers_checked << " out of " << n_receiver << " receivers.\n";
85 |
86 | return List::create(Named("pos_sender") = pos_sender, Named("exp_sender") = exp_sender);
87 | }
88 |
--------------------------------------------------------------------------------
/spacia/MICProB_MIL_C2Cinter.R:
--------------------------------------------------------------------------------
1 | # library(coda)
2 |
3 | #### Get hyperparameters ####
4 | getHyperPars <- function(tidydata){
5 | D = tidydata$nfeature_inst # pos (1) + exp (D-1)
6 | res = list(
7 | hp_mu_beta=rep(0, D),
8 | hp_mu_b=rep(0,2),
9 |
10 | hp_Sig_beta = diag(c(1,rep(1,D-1)),D),
11 | hp_Sig_b = diag(c(1,rep(1,1)),2)
12 |
13 | # Testing model priors
14 |
15 | # hp_Sig_beta = diag(c(5, rep(5, D-1)),D),
16 | # hp_Sig_b = diag(c(5, rep(5, 1)),2)
17 |
18 | # hp_Sig_beta = diag(c(1000,rep(1000,D-1)),D),
19 | # hp_Sig_b = diag(c(1000,rep(1000,1)),2)
20 |
21 | # hp_Sig_beta = diag(c(100,rep(100,D-1)),D),
22 | # hp_Sig_b = diag(c(100,rep(100,1)),2)
23 |
24 | # hp_Sig_beta = diag(c(10,rep(10,D-1)),D),
25 | # hp_Sig_b = diag(c(10,rep(10,1)),2)
26 | )
27 | return(res)
28 | }
29 |
30 | #### Get initial values ####
31 | getInits <- function(tidydata,hyperpars){
32 | beta = unlist(lapply(hyperpars$hp_mu_beta, function(mu_beta) rnorm(1, mu_beta, 10)))
33 | b = unlist(lapply(hyperpars$hp_mu_b, function(mu_b) rnorm(1, mu_b, 10)))
34 | delta = unlist(lapply(1:tidydata$nsample,function(i){rbinom(tidydata$ninst[i],1,mean(tidydata$label))}))
35 |
36 | res = list(
37 | beta = beta,
38 | b = b,
39 | delta = delta
40 | )
41 | return(res)
42 | }
43 |
44 |
45 | #### Summarize all input data and parameters for mcmc chain ####
46 | getInputPars <- function(tidydata){
47 |
48 | list_hyperpars <- getHyperPars(tidydata)
49 | list_inits <- getInits(tidydata,list_hyperpars)
50 |
51 | tmp=Reduce(rbind, tidydata$feature_inst)
52 | res = list(
53 | ## data
54 | n = tidydata$nsample, # number of bags
55 | d = tidydata$nfeature_inst, # number of features, pos (1) + exp (d-1)
56 | m = tidydata$ninst, # number of instances per bag
57 | membership = tidydata$membership, # membership for instances
58 | y = tidydata$label, # bag labels
59 | X1 = cbind(rep(1,dim(tmp)[1]),tmp), # design matrix
60 | ## hyperparameters
61 | hp_mu_beta = list_hyperpars$hp_mu_beta,
62 | hp_mu_b = list_hyperpars$hp_mu_b,
63 | hp_Sig_beta = list_hyperpars$hp_Sig_beta,
64 | hp_Sig_b = list_hyperpars$hp_Sig_b,
65 | ## model parameters
66 | beta = list_inits$beta,
67 | b = list_inits$b,
68 | delta = list_inits$delta
69 | )
70 | return(res)
71 | }
72 |
73 |
74 | #### Fitting BMIR2 model ####
75 |
76 | #### 1 Gibbs iteration in Rcpp ####
77 | MICProB_sampler<-function(tidytrain,
78 | tidytest,
79 | ntotal,
80 | nwarm,
81 | nthin,
82 | nchain,
83 | #scale,
84 | return_delta,
85 | prior = 1){
86 |
87 | cat("=============================================================\n")
88 | cat(sprintf("Probit Bayesian Multiple Instance Classification\n"))
89 |
90 | res_mcmc <- vector("list", nchain)
91 |
92 | for(nc in 1:nchain){
93 |
94 | # begin time
95 | start_time <- Sys.time()
96 |
97 | parlist <- getInputPars(tidytrain)
98 |
99 | y<-parlist$y
100 | n<-parlist$n
101 | d<-parlist$d
102 | m<-parlist$m
103 | N<-sum(m)
104 | membership<-parlist$membership
105 |
106 | hp_mu_beta<-parlist$hp_mu_beta
107 | hp_mu_b<-parlist$hp_mu_b
108 | hp_Sig_beta<-parlist$hp_Sig_beta
109 | hp_Sig_b<-parlist$hp_Sig_b
110 |
111 | if (prior != 1) {
112 | hp_Sig_beta = diag(c(prior, rep(prior, d-1)),d)
113 | hp_Sig_b = diag(c(prior, rep(prior, 1)),2)
114 | cat(sprintf("prior b and beta resetted.\n"))
115 | }
116 |
117 | beta<-parlist$beta
118 | b<-parlist$b
119 | delta<-parlist$delta
120 | u = rep(0,N)
121 | z = rep(0,n)
122 |
123 | hp_Sig_beta_inv<-solve(hp_Sig_beta)
124 | hp_Sig_b_inv<-solve(hp_Sig_b)
125 |
126 | # posterior variance of b
127 | X1 <- parlist$X1
128 | V_b <- solve(hp_Sig_b_inv + crossprod(X1[,1:2], X1[,1:2]))
129 |
130 | #cat("=============================================================\n")
131 | #cat(sprintf("Bayesian Multiple Instance Regression: chain" ,nc, " \n"))
132 |
133 | # begin time
134 | # start_time <- Sys.time()
135 |
136 | tick = 0.2
137 |
138 | # Gibbs sampling (warming up)
139 |
140 | cat("=============================================================\n")
141 | cat("Start warming up",nwarm,"MCMC samples!\n")
142 | cat("Progress: ")
143 |
144 | for(iter in 1:nwarm){
145 | if(iter %in% seq(round(tick*nwarm),nwarm,by=round(tick*nwarm))){
146 | cat(100*iter/nwarm,"% ...")
147 | }
148 | mcmc_res <- MICProB_1Gibbs_cpp(Xb = X1[,2,drop=F],Xbeta=X1[,-c(1,2), drop = F],
149 | y = y,
150 | ninst = m,
151 | hp_mu_beta = hp_mu_beta,
152 | hp_mu_b,
153 | hp_Sig_beta,
154 | hp_Sig_b,
155 | beta,
156 | b,
157 | delta,
158 | u,
159 | z,
160 | hp_Sig_beta_inv,
161 | hp_Sig_b_inv,
162 | V_b)
163 |
164 | # update parameters
165 | beta = mcmc_res$beta
166 | b = mcmc_res$b
167 | delta = mcmc_res$delta
168 | u = mcmc_res$u
169 | z = mcmc_res$z
170 |
171 | } # end warm-up
172 | cat("\n")
173 | cat("Finish warming up!\n")
174 | cat("-------------------------------------------------------------\n")
175 |
176 | niter = ntotal - nwarm
177 | nsave = 1 + floor((niter - 1) /nthin)
178 |
179 | # posterior quantities to be saved
180 | beta_post<-matrix(NA,nrow=nsave,ncol=length(beta))
181 | b_post<-matrix(NA,nrow=nsave,ncol=length(b))
182 | delta_post<-matrix(NA,nrow=nsave,ncol=length(delta))
183 |
184 | pip_1chain<-rep(0,length(delta))
185 | mcmc_1chain <- list()
186 |
187 | cat("Start extracting",niter,"MCMC samples!\n")
188 | cat("Progress :")
189 | for(iter in 1:niter){
190 | if(iter %in% seq(round(tick*niter),niter,by=round(tick*niter))){
191 | cat(100*iter/niter,"% ...")
192 | }
193 | mcmc_res <- MICProB_1Gibbs_cpp(Xb = X1[,2,drop=F],Xbeta=X1[,-c(1,2), drop = F],
194 | y = y,
195 | ninst = m,
196 | hp_mu_beta = hp_mu_beta,
197 | hp_mu_b,
198 | hp_Sig_beta,
199 | hp_Sig_b,
200 | beta,
201 | b,
202 | delta,
203 | u,
204 | z,
205 | hp_Sig_beta_inv,
206 | hp_Sig_b_inv,
207 | V_b)
208 |
209 | # update parmaeters
210 | beta = mcmc_res$beta
211 | b = mcmc_res$b
212 | delta = mcmc_res$delta
213 | u = mcmc_res$u
214 | z = mcmc_res$z
215 |
216 | # save posterior samples
217 | if(iter %in% seq(nthin,niter,by=nthin)){ # thinning delta
218 | if(return_delta){
219 | delta_post[iter/nthin,]<-delta
220 | }
221 | pip_1chain = pip_1chain + delta
222 | beta_post[iter/nthin,]<-beta
223 | b_post[iter/nthin,]<-b
224 | }
225 |
226 | } # end extracting posterior samples
227 |
228 | pip_1chain = pip_1chain / nsave
229 | cat("\n")
230 | cat("Finish MCMC sampling!\n")
231 | cat("=============================================================\n")
232 |
233 | # elapsed time
234 | cat(sprintf("Elapsed time for chain%d=%.3f mins: MCMC sampling is done!\n", nc, difftime(Sys.time(), start_time, units = "mins")))
235 |
236 | # output
237 | mcmc_1chain[["beta"]]<-rbind(parlist$beta,beta_post)
238 | mcmc_1chain[["b"]]<-rbind(parlist$b,b_post)
239 | mcmc_1chain[["pip"]]<-pip_1chain
240 |
241 | if(return_delta){
242 | mcmc_1chain[["delta"]]<-rbind(parlist$delta, delta_post)
243 | } else{
244 | mcmc_1chain[["delta"]]<-NULL
245 | }
246 |
247 | res_mcmc[[nc]]<-mcmc_1chain
248 |
249 | }
250 |
251 | return(res_mcmc)
252 | }
253 |
--------------------------------------------------------------------------------
/spacia/MIL_wrapper.R:
--------------------------------------------------------------------------------
1 | ######## simulate some very simple data ###################
2 | # for the purpose of debug and show the format of the input data
3 |
4 | # # bag level, expression of one gene in the receiver cell
5 | # # dichotomized by the users
6 | # exp_receiver=c(1,1,0,0)
7 | #
8 | # # instance features, distances of the sending cells to receiver cells
9 | # # each bag should have at least one instance
10 | # pos_sender=list(
11 | # c(1,4,3),
12 | # c(1),
13 | # c(1,5,2,3),
14 | # c(3)
15 | # )
16 | #
17 | # # instance features, expression of genes/pathways in the sending cells
18 | # # rows are genes/pathways, cols are instances
19 | # exp_sender=list(
20 | # matrix(runif(3*3),ncol=3),
21 | # matrix(runif(1*3),ncol=3),
22 | # matrix(runif(4*3),ncol=3),
23 | # matrix(runif(1*3),ncol=3)
24 | # )
25 | #
26 | # # MCMC parameters
27 | # ntotal=100
28 | # nwarm=10
29 | # nthin=10
30 | # nchain=1
31 | #
32 | # # cutoffs on the pi_hats
33 | # thetas=c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9)
34 | # res = MIL_C2Cinter(
35 | # exp_receiver, pos_sender, exp_sender, ntotal, nwarm, nthin, nchain, thetas)
36 |
37 | ########3 MIL wrapper #####################
38 |
39 | MIL_C2Cinter<-function(exp_receiver,pos_sender,exp_sender,
40 | ntotal,nwarm,nthin,nchain,thetas,prior)
41 | {
42 | # organize into Danyi's original format
43 | tidy_train=list()
44 | tidy_train$membership=unlist(sapply(1:length(exp_sender),
45 | function(i) rep(i,dim(exp_sender[[i]])[1])))
46 | tidy_train$ninst=sapply(exp_sender,function(x) dim(x)[1])
47 |
48 | tidy_train$label=exp_receiver
49 | tidy_train$nsample=length(exp_receiver)
50 |
51 | exp_pos_sender=exp_sender
52 | for (i in 1:length(exp_sender))
53 | {exp_pos_sender[[i]]=cbind(pos_sender[[i]],exp_pos_sender[[i]])}
54 |
55 | tidy_train$feature_inst=exp_pos_sender
56 | tidy_train$nfeature_inst=dim(exp_pos_sender[[1]])[2]
57 |
58 | tidytrain=tidy_train
59 | tidydata=tidy_train
60 |
61 | # invoke Danyi's functions
62 | res_mcmc=MICProB_sampler(tidytrain,
63 | tidytest=NULL,
64 | ntotal,
65 | nwarm,
66 | nthin,
67 | nchain,
68 | #scale,
69 | return_delta=TRUE,
70 | prior)
71 |
72 | # organize results
73 | pip=c() # col=nchain, row=number of senders
74 | for (nc in 1:nchain) {pip=cbind(pip,res_mcmc[[nc]]$pip)}
75 |
76 | b=c() # all samples of all MCMC chains
77 | for (nc in 1:nchain) {b=rbind(b,res_mcmc[[nc]]$b)}
78 |
79 | beta=c() # col=number of features, row=all samples of all chains
80 | beta_mean=beta_var=c()
81 | for (nc in 1:nchain)
82 | {
83 | tmp=res_mcmc[[nc]]$beta[,-1,drop=F]
84 | beta=rbind(beta,tmp)
85 | beta_mean=rbind(beta_mean,colMeans(tmp))
86 | beta_var=rbind(beta_var,apply(tmp,2,var))
87 | }
88 |
89 | FDRs=sapply(thetas,function(theta) { # B-FDRs
90 | sum((pip>theta)*(1-pip))/sum(pip>theta)
91 | })
92 |
93 | # PSRF
94 | N=dim(res_mcmc[[1]]$beta)[1]
95 | M=nchain
96 | B=N/(M-1)*rowSums((t(beta_mean)-colMeans(beta_mean))^2)
97 | W=colMeans(beta_var)
98 | V_hat=(N-1)/N*W+(M+1)/M/N*B
99 | PSRF=V_hat/W
100 |
101 | # recalculate a point-estiate of the probability of primary instances
102 | # to avoid the negative impact of randomness in MCMC sampling
103 | # this still is not ideal
104 | # good enough to use it as a "score" to indicate primary instance
105 | # but cannot interpret it as a probability (as it should be)
106 |
107 | pip_recal=c()
108 | b0=mean(b[,1])
109 | b1=mean(b[,2])
110 | for (i in 1:length(pos_sender))
111 | {pip_recal=c(pip_recal,pnorm(b0+pos_sender[[i]]*b1))}
112 |
113 | # (1) pip is the probabilities of the sender cells being truly responsible for the
114 | # receiving cells' phenotypes
115 | # (2) b is the coef for explaining how the distances between sender and receiver cells
116 | # affect the probabilities of the sender cells being responsible
117 | # (3) beta are the coefs for explaining the effect of the expression of the genes
118 | # in the sender cells
119 | # (4) FDRs are the Bayes FDRs calculated according to the theta
120 | # cutoffs given by the users (for defining primary instances)
121 | # (5) recalculated pip
122 | # (6) PSRF of beta
123 | return(list(pip=pip,b=b,beta=beta,FDRs=FDRs,pip_recal=pip_recal,
124 | PSRF=PSRF))
125 | }
126 |
--------------------------------------------------------------------------------
/spacia/Workflow_Helpers.py:
--------------------------------------------------------------------------------
1 | # Standard library imports
2 | import os
3 | from dataclasses import dataclass
4 | from typing import List, Optional, Tuple
5 |
6 | # Third-party library imports
7 | import numpy as np
8 | import pandas as pd
9 | from matplotlib import pyplot as plt
10 | from matplotlib.path import Path
11 | from scipy import stats
12 | from scipy.stats import gaussian_kde
13 | from scipy.spatial import ConvexHull
14 |
15 | def process_spacia_data(receiving_cell: str, sending_cell: str, directory: str) -> Tuple[pd.DataFrame, pd.DataFrame]:
16 | """
17 | Process Spacia data files from a given directory, combining beta and pip files.
18 |
19 | This function walks through the specified directory, processes 'betas.csv' and 'pip.csv' files,
20 | and combines them into two separate DataFrames.
21 |
22 | Parameters:
23 | receiving_cell (str): Identifier for the receiving cell type
24 | sending_cell (str): Identifier for the sending cell type
25 | directory (str): Path to the directory containing the data files
26 |
27 | Returns:
28 | Tuple[pd.DataFrame, pd.DataFrame]: A tuple containing two DataFrames:
29 | - combined_betas: DataFrame with combined data from all 'betas.csv' files
30 | - combined_pip: DataFrame with combined data from all 'pip.csv' files
31 | """
32 | def read_csv_files(file_paths: List[str]) -> pd.DataFrame:
33 | """Read and combine multiple CSV files into a single DataFrame."""
34 | return pd.concat([pd.read_csv(file) for file in file_paths], ignore_index=True)
35 |
36 | beta_files = []
37 | pip_files = []
38 |
39 | # Walk through the directory and collect file paths
40 | for root, _, files in os.walk(directory):
41 | for file in files:
42 | file_path = os.path.join(root, file)
43 | if file.endswith('betas.csv'):
44 | beta_files.append(file_path)
45 | elif file.endswith('pip.csv'):
46 | pip_files.append(file_path)
47 |
48 | # Process beta files
49 | if beta_files:
50 | combined_betas = read_csv_files(beta_files)
51 | combined_betas['sending_cell'] = sending_cell
52 | combined_betas['receiving_cell'] = receiving_cell
53 | else:
54 | combined_betas = pd.DataFrame()
55 |
56 | # Process pip files
57 | combined_pip = read_csv_files(pip_files) if pip_files else pd.DataFrame()
58 |
59 | return combined_betas, combined_pip
60 |
61 | # Example usage:
62 | # betas_df, pip_df = process_spacia_data("TumorCells", "EndothelialCells", "/path/to/data/directory")
63 |
64 |
65 |
66 | def calculate_weighted_activation_scores(expression_data: pd.DataFrame,
67 | cell_metadata: pd.DataFrame,
68 | beta_values: pd.DataFrame,
69 | pi_scores: pd.DataFrame,
70 | proximity_dict: dict,
71 | receiver_type: str,
72 | sender_type: str,
73 | sending_genes: list,
74 | receiving_genes: list,
75 | score_name: str) -> pd.DataFrame:
76 | """
77 | Calculate weighted activation scores for cell-cell interactions based on gene expression,
78 | interaction strengths, and spatial proximity.
79 |
80 | Parameters:
81 | expression_data (pd.DataFrame): Gene expression data (cells as rows, genes as columns)
82 | cell_metadata (pd.DataFrame): Cell metadata including cell type
83 | beta_values (pd.DataFrame): Beta values for gene interactions
84 | pi_scores (pd.DataFrame): Primary instance scores
85 | proximity_dict (dict): Dictionary of receiver cells and their nearby sender cells
86 | receiver_type (str): Cell type of the receiver cells
87 | sender_type (str): Cell type of the sender cells
88 | sending_genes (list): List of sending genes to consider
89 | receiving_genes (list): List of receiving genes to consider
90 | score_name (str): Name of the activation score
91 |
92 | Returns:
93 | pd.DataFrame: Final data with weighted activation scores for each receiver cell
94 | """
95 |
96 | def calculate_activation_scores(proximity_dict: dict,
97 | beta_filtered: pd.DataFrame,
98 | exp_data: pd.DataFrame) -> pd.DataFrame:
99 | """Calculate activation scores for cells using the pre-computed proximity dictionary."""
100 | activation_scores = []
101 | unique_sender_cells = set(cell for cells in proximity_dict.values() for cell in cells)
102 |
103 | for sender_cell in unique_sender_cells:
104 | cell_expression = exp_data.loc[sender_cell]
105 | merged_data = beta_filtered.merge(cell_expression, left_on='sending_gene', right_index=True, how='left')
106 | merged_data['expression'] = merged_data.iloc[:, -1]
107 | merged_data['score'] = np.maximum(0, merged_data['avg_beta_sampled']) * merged_data['expression']
108 |
109 | activation_scores.append({
110 | 'sending_cell': sender_cell,
111 | 'activation_score': merged_data['score'].sum()
112 | })
113 |
114 | return pd.DataFrame(activation_scores)
115 |
116 | # Filter beta values
117 | beta_filtered = beta_values[
118 | (beta_values['b'] < 0) &
119 | (beta_values['sending_gene'].isin(sending_genes)) &
120 | (beta_values['receiving_gene'].isin(receiving_genes)) &
121 | (beta_values['sending_cell'] == sender_type) &
122 | (beta_values['receiving_cell'] == receiver_type)
123 | ]
124 |
125 | # Calculate activation scores
126 | activation_scores = calculate_activation_scores(proximity_dict, beta_filtered, expression_data)
127 |
128 | # Summarize PI scores
129 | pi_summary = pi_scores.groupby(['receiving_cell', 'sending_cell'])['avg_primary_instance_score'].mean().reset_index()
130 |
131 | # Merge activation scores with PI scores
132 | merged_scores = pi_summary.merge(activation_scores, on='sending_cell', how='left')
133 | merged_scores['weighted_score'] = merged_scores['avg_primary_instance_score'] * merged_scores['activation_score']
134 |
135 | # Calculate final scores for each receiving cell
136 | final_scores = []
137 | for receiver, senders in proximity_dict.items():
138 | cell_scores = merged_scores[
139 | (merged_scores['receiving_cell'].astype(str) == str(receiver)) &
140 | (merged_scores['sending_cell'].isin([str(cell) for cell in senders]))
141 | ]
142 | if not cell_scores.empty:
143 | final_scores.append({
144 | 'receiving_cell': receiver,
145 | score_name: cell_scores['weighted_score'].sum()
146 | })
147 |
148 | final_scores_df = pd.DataFrame(final_scores)
149 |
150 | # Merge with receiver cell metadata
151 | receiver_cells = cell_metadata[cell_metadata['cell_type'] == receiver_type].reset_index()
152 | final_data = receiver_cells.merge(final_scores_df,
153 | left_on='index',
154 | right_on='receiving_cell',
155 | how='inner')
156 |
157 | return final_data
158 |
159 | # Example usage:
160 | # result = calculate_weighted_activation_scores(
161 | # expression_data=expression_data,
162 | # cell_metadata=cell_metadata,
163 | # beta_values=beta_values,
164 | # pi_scores=pi_scores,
165 | # proximity_dict=proximity_dict,
166 | # receiver_type="Tumor Cells",
167 | # sender_type="Endothelial Cells",
168 | # sending_genes=["HGF", "WNT5A", "FGF2", "IL6", "CXCL8", "FGF1", "TGFB1", "TGFB2"],
169 | # receiving_genes=["JAK1", "AKT2", "SMO", "CTNNB1", "SMAD2", "NFKB2"],
170 | # score_name="Endothelial_Activation_Score"
171 | # )
172 |
173 |
174 |
175 |
176 | @dataclass
177 | class SpatialScore:
178 | """
179 | Class to hold spatial scoring results and perform density estimation
180 |
181 | Attributes:
182 | score_data (pd.DataFrame): DataFrame containing cell coordinates and scores
183 | score_name (str): Name of the score (e.g. "EMT", "Activation")
184 | mask (Optional[np.ndarray]): Custom binary mask for the tissue area
185 | xi (Optional[np.ndarray]): Optional x coordinates of the grid
186 | yi (Optional[np.ndarray]): Optional y coordinates of the grid
187 | """
188 | score_data: pd.DataFrame
189 | score_name: str
190 | mask: Optional[np.ndarray] = None
191 | xi: Optional[np.ndarray] = None
192 | yi: Optional[np.ndarray] = None
193 |
194 | def __post_init__(self):
195 | self.x_coords = self.score_data['X'].values
196 | self.y_coords = self.score_data['Y'].values
197 | self.scores = self.score_data[self.score_name].values
198 |
199 | # Initialize as None, compute only when needed
200 | self._kde = None
201 | self._density = None
202 | self._hull_mask = None
203 |
204 | # Validate xi and yi if provided
205 | if (self.xi is not None) != (self.yi is not None):
206 | raise ValueError("Both xi and yi must be provided together")
207 |
208 | if self.xi is not None:
209 | if self.xi.shape != self.yi.shape:
210 | raise ValueError("xi and yi must have the same shape")
211 | self._xi = self.xi
212 | self._yi = self.yi
213 | else:
214 | self._xi = None
215 | self._yi = None
216 |
217 | def compute_kde(self, bandwidth: float = 0.1, grid_size: int = 300):
218 | """
219 | Compute kernel density estimation
220 |
221 | Parameters:
222 | bandwidth: KDE bandwidth parameter
223 | grid_size: Size of the grid (used only if xi/yi not provided at init)
224 | """
225 | # Compute KDE
226 | self._kde = gaussian_kde(
227 | np.vstack([self.x_coords, self.y_coords]),
228 | weights=self.scores,
229 | bw_method=bandwidth
230 | )
231 |
232 | # Create grid if not provided
233 | if self._xi is None:
234 | x_min, x_max = self.x_coords.min(), self.x_coords.max()
235 | y_min, y_max = self.y_coords.min(), self.y_coords.max()
236 | self._xi, self._yi = np.mgrid[x_min:x_max:grid_size*1j,
237 | y_min:y_max:grid_size*1j]
238 |
239 | # Compute density
240 | positions = np.vstack([self._xi.ravel(), self._yi.ravel()])
241 | self._density = self._kde(positions).reshape(self._xi.shape)
242 |
243 | # Generate automatic hull mask if no custom mask provided
244 | if self.mask is None:
245 | self._generate_hull_mask()
246 | else:
247 | if self.mask.shape != self._xi.shape:
248 | raise ValueError("Provided mask shape must match grid shape")
249 | self._hull_mask = self.mask
250 |
251 | return self
252 |
253 | def _generate_hull_mask(self):
254 | """Generate convex hull mask for the tissue area"""
255 | coords = np.column_stack([self.x_coords, self.y_coords])
256 | hull = ConvexHull(coords)
257 | hull_points = coords[hull.vertices]
258 |
259 | # Create mask using hull
260 | points = np.vstack([self._xi.ravel(), self._yi.ravel()]).T
261 | hull_path = Path(hull_points)
262 | self._hull_mask = hull_path.contains_points(points).reshape(self._xi.shape)
263 |
264 |
265 | def get_masked_density(self) -> np.ndarray:
266 | """Return density values masked by tissue area"""
267 | if self._density is None:
268 | self.compute_kde()
269 | return np.where(self._hull_mask, self._density, np.nan)
270 |
271 | def plot(self, cmap: str = 'viridis', title: Optional[str] = None):
272 | """Plot the spatial distribution of scores"""
273 | if self._density is None:
274 | self.compute_kde()
275 |
276 | plt.figure(figsize=(10, 8))
277 | plt.contourf(self._xi, self._yi, self.get_masked_density(),
278 | cmap=cmap, alpha=0.6)
279 |
280 | if title:
281 | plt.title(title)
282 | plt.colorbar(label=f'KDE of {self.score_name}')
283 | plt.axis('off')
284 | return plt.gca()
285 |
286 |
287 | # Helper function to create common grid for multiple scores
288 | def create_common_grid(score_objects: List[SpatialScore],
289 | grid_size: int = 300) -> Tuple[np.ndarray, np.ndarray]:
290 | """
291 | Create a common grid for multiple spatial scores
292 |
293 | Parameters:
294 | score_objects: List of SpatialScore objects
295 | grid_size: Size of the grid
296 |
297 | Returns:
298 | xi, yi: Grid coordinates
299 | """
300 | # Find common bounds
301 | x_min = min(obj.x_coords.min() for obj in score_objects)
302 | x_max = max(obj.x_coords.max() for obj in score_objects)
303 | y_min = min(obj.y_coords.min() for obj in score_objects)
304 | y_max = max(obj.y_coords.max() for obj in score_objects)
305 |
306 | # Create common grid
307 | xi, yi = np.mgrid[x_min:x_max:grid_size*1j,
308 | y_min:y_max:grid_size*1j]
309 |
310 | return xi, yi
311 |
312 | def compute_correlation(score1: SpatialScore,
313 | score2: SpatialScore,
314 | method: str = 'spearman') -> Tuple[float, float]:
315 | """
316 | Compute correlation between two spatial scores
317 |
318 | Parameters:
319 | score1, score2: SpatialScore objects
320 | method: 'spearman' or 'pearson'
321 |
322 | Returns:
323 | correlation coefficient and p-value
324 | """
325 | if score1._density is None:
326 | score1.compute_kde()
327 | if score2._density is None:
328 | score2.compute_kde()
329 |
330 | # Get masked values
331 | masked1 = score1.get_masked_density().ravel()
332 | masked2 = score2.get_masked_density().ravel()
333 |
334 | # Remove NaN values
335 | valid_idx = ~(np.isnan(masked1) | np.isnan(masked2))
336 | masked1 = masked1[valid_idx]
337 | masked2 = masked2[valid_idx]
338 |
339 | if method == 'spearman':
340 | return stats.spearmanr(masked1, masked2)
341 | elif method == 'pearson':
342 | return stats.pearsonr(masked1, masked2)
343 | else:
344 | raise ValueError("Method must be 'spearman' or 'pearson'")
345 |
346 | def create_common_mask(score_objects: List[SpatialScore], xi: np.ndarray, yi: np.ndarray) -> np.ndarray:
347 | """
348 | Create a common mask using all cell coordinates from all score objects
349 |
350 | Parameters:
351 | score_objects: List of SpatialScore objects
352 | xi, yi: Grid coordinates
353 |
354 | Returns:
355 | mask: Common binary mask
356 | """
357 | # Combine all cell coordinates
358 | all_x_coords = np.concatenate([obj.x_coords for obj in score_objects])
359 | all_y_coords = np.concatenate([obj.y_coords for obj in score_objects])
360 |
361 | # Create convex hull from all coordinates
362 | coords = np.column_stack([all_x_coords, all_y_coords])
363 | hull = ConvexHull(coords)
364 | hull_points = coords[hull.vertices]
365 |
366 | # Create mask using hull
367 | points = np.vstack([xi.ravel(), yi.ravel()]).T
368 | hull_path = Path(hull_points)
369 | return hull_path.contains_points(points).reshape(xi.shape)
370 |
371 | # Example usage:
372 | # """
373 | #
374 | # endo_score = pd.DataFrame({
375 | # 'index': ['cell_2', 'cell_8', ...], # object (str)
376 | # 'X': [23.5, 45.2, ...], # float64
377 | # 'Y': [-12.3, 8.7, ...], # float64
378 | # 'cell_type': ['Tumor_Cells', 'Tumor_Cells', ...], # object (str)
379 | # 'receiving_cell': ['cell_5', 'cell_8', ...], # object (str)
380 | # 'Endothelial_Activation_Score': [0.85, 0.92, ...] # float64
381 | # })
382 | #
383 | # fibro_score = pd.DataFrame({
384 | # 'index': ['cell_4', 'cell_10', ...], # object (str)
385 | # 'X': [23.5, 45.2, ...], # float64
386 | # 'Y': [-12.3, 8.7, ...], # float64
387 | # 'cell_type': ['Tumor_Cells', 'Tumor_Cells',...], # object (str)
388 | # 'receiving_cell': ['cell_45', 'cell_23', ...],# object (str)
389 | # 'Fibroblast_Activation_Score': [0.80, 0.32, ...] # float64
390 | # }
391 | #
392 | # # Create objects without computing KDE
393 | # endo_spatialscore = SpatialScore(endo_score, 'Endothelial_Activation_Score')
394 | # fibro_spatialscore = SpatialScore(fibro_score, 'Fibroblast_Activation_Score')
395 | #
396 | # # Create common grid
397 | # xi, yi = create_common_grid([endo_spatialscore, fibro_spatialscore])
398 | # common_mask = create_common_mask([endo_spatialscore, fibro_spatialscore, tumor_spatialscore], xi, yi)
399 | #
400 | # # Create new objects with common grid
401 | # endo_spatialscore = SpatialScore(endo_score, 'Endothelial_Activation_Score' xi=xi, yi=yi)
402 | # fibro_spatialscore = SpatialScore(fibro_score, 'Fibroblast_Activation_Score' xi=xi, yi=yi)
403 | #
404 | # # Compute KDE and correlations
405 | # endo_spatialscore.compute_kde()
406 | # fibro_spatialscore.compute_kde()
407 |
408 | # corr, pval = compute_correlation(endo_spatialscore, fibro_spatialscore)
409 | # """
410 |
411 |
412 |
--------------------------------------------------------------------------------
/spacia/spacia_job.R:
--------------------------------------------------------------------------------
1 | # This is a wrapper script for MIL_wrapper.R, serving as the interface between
2 | # python master script and the MIL model. The only usage for this script so far
3 | # is to be called by the python wrapper.
4 | # Debug data
5 | # setwd('E:/projects/cell2cell_inter/code/data/simulation/')
6 | # spacia_path = './spacia/'
7 | # exp_receiver = 'exp_receiver.csv'
8 | # exp_sender = 'exp_sender.json'
9 | # dist_sender = 'dist_sender.json'
10 | # ntotal=8000
11 | # nwarm=4000
12 | # nthin=10
13 | # nchain=4
14 | # thetas=c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9)
15 | # output_path = ''
16 | # job_id = ''
17 |
18 | # Dummy test data
19 | # exp_receiver=c(1,1,0,0)
20 | # pos_sender=list(
21 | # c(1,4,3),
22 | # c(1),
23 | # c(1,5,2,3,6),
24 | # c(3)
25 | # )
26 | #
27 | # # instance features, expression of genes/pathways in the sending cells
28 | # # rows are genes/pathways, cols are instances
29 | # exp_sender=list(
30 | # matrix(runif(3*3),ncol=3),
31 | # matrix(runif(1*3),ncol=3),
32 | # matrix(runif(5*3),ncol=3),
33 | # matrix(runif(1*3),ncol=3)
34 | # )
35 | #
36 | # # MCMC parameters
37 | # ntotal=100
38 | # nwarm=10
39 | # nthin=10
40 | # nchain=1
41 | #
42 | # # cutoffs on the pi_hats
43 | # thetas=c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9)
44 |
45 | ######## Setting up ########
46 |
47 | args = commandArgs(trailingOnly=TRUE)
48 | spacia_path = args[1]
49 | exp_sender = args[2]
50 | dist_sender = args[3]
51 | exp_receiver = args[4]
52 | job_id = args[5]
53 | ntotal = as.integer(args[6])
54 | nwarm = as.integer(args[7])
55 | nthin = as.integer(args[8])
56 | nchain = as.integer(args[9])
57 | output_path = args[10] # output path need to have '/' at the end
58 | plot_mcmc = as.logical(args[11]) # whether or not to plot diagnosis plots
59 | ext = args[12] # extension used for the ggsave. see BetaB2MCMCPlots.R
60 | # input for prior without breaking the other functions.
61 | if (is.na(args[13])) {
62 | prior = 1
63 | } else {
64 | prior = as.numeric(args[13])
65 | }
66 | thetas = c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9)
67 |
68 | # redirect logs
69 | sink(
70 | file = paste(output_path, job_id, '_log.txt', sep=''),
71 | type = c("output", "message"))
72 | suppressPackageStartupMessages(library(Rcpp))
73 | suppressPackageStartupMessages(library(rjson))
74 |
75 | ######### source codes #################
76 | sourceCpp(paste(spacia_path,"Fun_MICProB_C2Cinter.cpp", sep=''))
77 | source(paste(spacia_path,'MICProB_MIL_C2Cinter.R', sep=''))
78 | source(paste(spacia_path,'MIL_wrapper.R', sep=''))
79 | source(paste(spacia_path,'BetaB2MCMCPlots.R', sep=''))
80 | print('Depdendencies are successfully loaded.')
81 | ######## format input into proper formats ########
82 |
83 | # Read receiver matrix
84 | exp_receiver = read.csv(
85 | exp_receiver, header=F, row.names = NULL, stringsAsFactors = F)$V1
86 | exp_receiver = exp_receiver == 1
87 |
88 | # Read sender expression
89 | tmp = fromJSON(file=exp_sender)
90 | exp_sender = sapply(tmp, function (x) do.call(rbind, as.list(x)))
91 |
92 | # exp_sender = sapply(exp_sender, function (x) do.call(rbind, as.list(x))) # Fixed bug causing error when there is only one signal
93 |
94 | # Read sender distance to receivers
95 | dist_sender = fromJSON(file=dist_sender)
96 | # Normalize distance with the maximal distance
97 | max_dist = max(sapply(dist_sender, function(x) x[which.max(abs(x))]))
98 | dist_sender = sapply(dist_sender, function(x) x / max_dist)
99 |
100 | # Run the model
101 | set.seed(0)
102 | t0 = Sys.time()
103 | res = MIL_C2Cinter(
104 | exp_receiver, dist_sender, exp_sender,
105 | ntotal, nwarm, nthin, nchain, thetas, prior)
106 | t1 = Sys.time()
107 | print(t1-t0)
108 | # Get memory use
109 | gc()
110 | # save job result to disk
111 | for (n in names(res)) {
112 | if (n == 'FDRs') {
113 | fdr = res$FDRs
114 | fdr[is.na(fdr)] = 1
115 | write.table(
116 | fdr, paste(output_path, job_id,'_',n,'.txt', sep=''), sep='\t')
117 | } else {
118 | write.table(
119 | res[n], paste(output_path, job_id,'_',n,'.txt', sep=''), sep='\t')
120 | }
121 | }
122 |
123 | ########### Plot MCMC Diagnostics ##############
124 | if (plot_mcmc) {
125 |
126 | beta_matrix = as.matrix(res$beta)
127 | b_matrix = as.matrix(res$b)
128 | colnames(beta_matrix) = paste("beta.", 1:dim(beta_matrix)[2], sep="")
129 | colnames(b_matrix) = c("b.1", "b.2")
130 |
131 | S <- BetaB2MCMCPlots(beta_matrix,
132 | b_matrix,
133 | nwarm,
134 | ntotal,
135 | nthin,
136 | nchain,
137 | job_id,
138 | output_path,
139 | ext)
140 |
141 | }
--------------------------------------------------------------------------------
/test.py:
--------------------------------------------------------------------------------
1 | import os
2 | import platform
3 |
4 | os_type = platform.system()
5 | spacia_path = os.path.abspath(__file__)
6 | spacia_fn = spacia_path.replace('test.py', 'spacia.py')
7 | input_path = spacia_path.replace('test.py', 'test/input')
8 | test_path = spacia_path.replace('test.py', 'test')
9 | counts_fn = os.path.join(input_path,'counts.txt')
10 | meta_fn = os.path.join(input_path,'spacia_metadata.txt')
11 |
12 | print('Testing Spacia with a single gene as response feature and simple aggregation')
13 | params = '-rc A -sc B -rf gene1 -sf gene2,gene3 -d 5 -m 2000,1000,10,1 -nc 20'
14 | output_path = os.path.join(test_path,'single_gene_simple_agg')
15 | cmd = 'python {} {} {} {} -o {}'.format(
16 | spacia_fn, counts_fn, meta_fn, params, output_path)
17 | codes = os.system(cmd)
18 | if codes == 0:
19 | print('Test Succeeded.')
20 | else:
21 | print('Test failed, please check log at {}'.format(output_path))
22 |
23 | print('Testing Spacia with multiple genes as response feature and no agg mode')
24 | output_path = os.path.join(test_path,'multi_gene_no_agg')
25 | params = '-rc A -sc B -rf "gene1|gene2|gene3" -sf gene2,gene3 -d 5 -m 2000,1000,10,1 -rec auto'
26 | cmd = 'python {} {} {} {} -o {}'.format(
27 | spacia_fn, counts_fn, meta_fn, params, output_path)
28 | codes = os.system(cmd)
29 | if codes == 0:
30 | print('Test Succeeded.')
31 | else:
32 | print('Test failed, please check log at {}'.format(output_path))
33 |
34 | print('Testing Spacia with multiple genes as response feature and pca agg mode')
35 | output_path = os.path.join(test_path,'multi_gene_pca_agg')
36 | params = '-rc A -sc B -rf "gene1|gene2|gene3" -sf pca -d 5 -m 2000,1000,10,1'
37 | cmd = 'python {} {} {} {} -o {}'.format(
38 | spacia_fn, counts_fn, meta_fn, params, output_path)
39 | codes = os.system(cmd)
40 | if codes == 0:
41 | print('Test Succeeded.')
42 | else:
43 | print('Test failed, please check log at {}'.format(output_path))
44 |
45 |
--------------------------------------------------------------------------------
/test/input/gene_cutoffs_A-B.txt:
--------------------------------------------------------------------------------
1 | gene_name cor_cutoff quantile_cutoff
2 | gene2 0.252 0.091
3 |
4 |
--------------------------------------------------------------------------------
/tutorials/demo_data/base_10_pathways/betas.csv:
--------------------------------------------------------------------------------
1 | ,Val
2 | True_beta,-10.399465230972362
3 | True_beta,12.078321989859917
4 | True_beta,-13.064702009420014
5 | True_beta,17.122010638859535
6 | True_beta,13.126022593699592
7 | True_beta,18.28350497045004
8 | True_beta,23.88372884855564
9 | True_beta,-19.343042662424704
10 | True_beta,-11.693603424651958
11 | True_beta,14.878722388708711
12 | Trivial_beta,-1.1852960623075917
13 | Trivial_beta,-0.5243352963077823
14 | Trivial_beta,-0.784060566578211
15 | Trivial_beta,0.7342599859539053
16 | Trivial_beta,0.25068089916688635
17 | Trivial_beta,-1.5073122180717866
18 | Trivial_beta,-0.34050440262471326
19 | Trivial_beta,1.0623321836928339
20 | Trivial_beta,-0.6310277236825583
21 | Trivial_beta,1.076862476037293
22 | Trivial_beta,0.4074993668018959
23 | Trivial_beta,-0.8658398701699223
24 | Trivial_beta,0.044267456148110784
25 | Trivial_beta,0.5710045694464371
26 | Trivial_beta,-2.0243902624622305
27 | Trivial_beta,1.4613483372336322
28 | Trivial_beta,-0.6076745789770274
29 | Trivial_beta,1.2416545370962297
30 | Trivial_beta,0.845904699354946
31 | Trivial_beta,0.08630278884927084
32 | Trivial_beta,-0.21516216401058086
33 | Trivial_beta,1.5059152906073696
34 | Trivial_beta,1.5247505207940149
35 | Trivial_beta,0.18583143996303228
36 | Trivial_beta,-0.8669176343055369
37 | Trivial_beta,-0.7216849662793661
38 | Trivial_beta,-1.0791630057397266
39 | Trivial_beta,1.3767090702136229
40 | Trivial_beta,0.31732667836424705
41 | Trivial_beta,2.425339881661556
42 | Trivial_beta,0.2967488112363
43 | Trivial_beta,-0.1425577326827625
44 | Trivial_beta,-1.0556067270633962
45 | Trivial_beta,0.47407062264062905
46 | Trivial_beta,0.24040581506805392
47 | Trivial_beta,-0.8802546092093041
48 | Trivial_beta,0.00395217019108102
49 | Trivial_beta,1.376567138334336
50 | Trivial_beta,-0.874795069215703
51 | Trivial_beta,1.344569729859562
52 |
--------------------------------------------------------------------------------
/tutorials/demo_data/base_10_pathways/spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_FDRs.txt:
--------------------------------------------------------------------------------
1 | "x"
2 | "1" 0.53891671884784
3 | "2" 0.438353147937558
4 | "3" 0.358435647847718
5 | "4" 0.290302933333333
6 | "5" 0.230128533018559
7 | "6" 0.180937700706487
8 | "7" 0.136325178389399
9 | "8" 0.091945868945869
10 | "9" 0.0474108527131783
11 |
--------------------------------------------------------------------------------
/tutorials/demo_data/base_10_pathways/spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_PSRF.txt:
--------------------------------------------------------------------------------
1 | "PSRF"
2 | "1" 0.997538438433216
3 | "2" 0.996684046128561
4 | "3" 1.00636666339511
5 | "4" 1.00465354880838
6 | "5" 1.0038688193145
7 | "6" 0.997676624336421
8 | "7" 1.00208326409072
9 | "8" 1.00144651897036
10 | "9" 1.00139882031078
11 | "10" 1.01043946566234
12 | "11" 1.00771104970187
13 | "12" 0.996679121433983
14 | "13" 0.997710576589315
15 | "14" 0.996684963510711
16 | "15" 0.996811320283303
17 | "16" 1.0047519925978
18 | "17" 0.997821122028424
19 | "18" 1.00295084090874
20 | "19" 1.00631369533374
21 | "20" 1.00536745648486
22 | "21" 0.999177224517183
23 | "22" 1.00058841227837
24 | "23" 0.997260450882091
25 | "24" 0.998757507231207
26 | "25" 0.998145805192903
27 | "26" 1.00012161541545
28 | "27" 1.00687553183782
29 | "28" 0.999783021249364
30 | "29" 1.00287557942918
31 | "30" 1.00117278846799
32 | "31" 1.00586098708962
33 | "32" 1.00130879350789
34 | "33" 0.997571065491425
35 | "34" 1.00663170962565
36 | "35" 0.996986260605292
37 | "36" 1.00556783571377
38 | "37" 0.996731878507186
39 | "38" 0.99737398126726
40 | "39" 1.00007108810879
41 | "40" 0.998223419242064
42 | "41" 0.998674709338537
43 | "42" 0.998422743128888
44 | "43" 1.00883564048981
45 | "44" 1.00252429344091
46 | "45" 0.997765694146599
47 | "46" 1.00204813315668
48 | "47" 1.00520026900674
49 | "48" 1.01106759329259
50 | "49" 0.998248558303597
51 | "50" 0.998870319600693
52 |
--------------------------------------------------------------------------------
/tutorials/demo_data/base_10_pathways/spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_base_10_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_log.txt:
--------------------------------------------------------------------------------
1 | =============================================================
2 | Probit Bayesian Multiple Instance Classification
3 | =============================================================
4 | Start warming up 20000 MCMC samples!
5 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
6 | Finish warming up!
7 | -------------------------------------------------------------
8 | Start extracting 30000 MCMC samples!
9 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
10 | Finish MCMC sampling!
11 | =============================================================
12 | Elapsed time for chain1=45.341 mins: MCMC sampling is done!
13 | =============================================================
14 | Start warming up 20000 MCMC samples!
15 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
16 | Finish warming up!
17 | -------------------------------------------------------------
18 | Start extracting 30000 MCMC samples!
19 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
20 | Finish MCMC sampling!
21 | =============================================================
22 | Elapsed time for chain2=45.205 mins: MCMC sampling is done!
23 | Time difference of 1.509171 hours
24 | used (Mb) gc trigger (Mb) max used (Mb)
25 | Ncells 458105 24.5 978064 52.3 654431 35.0
26 | Vcells 1231340 9.4 9804476 74.9 12255485 93.6
27 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_FDRs.txt:
--------------------------------------------------------------------------------
1 | "x"
2 | "1" 0.523917953445494
3 | "2" 0.471624451803455
4 | "3" 0.417858755240245
5 | "4" 0.352402172399387
6 | "5" 0.280981595092025
7 | "6" 0.212511640646398
8 | "7" 0.14810168101681
9 | "8" 0.0957262750161395
10 | "9" 0.0446556473829201
11 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_PSRF.txt:
--------------------------------------------------------------------------------
1 | "PSRF"
2 | "1" 1.3446212336483
3 | "2" 2.22449299382606
4 | "3" 1.27279791632377
5 | "4" 1.80111087124099
6 | "5" 0.98643227212266
7 | "6" 1.18635937876893
8 | "7" 0.987210691295428
9 | "8" 1.21474373024711
10 | "9" 1.20039314926074
11 | "10" 1.42176381122393
12 | "11" 1.15070652526909
13 | "12" 1.07659794815318
14 | "13" 1.20863623446392
15 | "14" 1.06452205079671
16 | "15" 1.03537147902855
17 | "16" 1.12870916217288
18 | "17" 1.14458653658139
19 | "18" 2.90255684729066
20 | "19" 1.05354794539151
21 | "20" 1.34134207774212
22 | "21" 1.12426888969217
23 | "22" 0.987667708039807
24 | "23" 1.60589905325492
25 | "24" 0.993158341425507
26 | "25" 1.13216491280706
27 | "26" 1.08545438449755
28 | "27" 1.04692657683225
29 | "28" 0.988001083847763
30 | "29" 0.981007875237065
31 | "30" 3.75433620093124
32 | "31" 2.14606732931185
33 | "32" 1.00845028465626
34 | "33" 1.02513287112374
35 | "34" 1.35814820890383
36 | "35" 1.02968248181863
37 | "36" 1.27512863719817
38 | "37" 1.33516315565741
39 | "38" 0.984476915922304
40 | "39" 1.47036917036474
41 | "40" 1.00422252831963
42 | "41" 1.21207683924423
43 | "42" 1.08103418147362
44 | "43" 1.58738813764436
45 | "44" 0.991520003141125
46 | "45" 1.41108821817984
47 | "46" 1.11797072767966
48 | "47" 1.28972015290608
49 | "48" 0.99994133476696
50 | "49" 1.01142984764584
51 | "50" 1.04343936547934
52 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_autocorr.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_autocorr.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_b.txt:
--------------------------------------------------------------------------------
1 | "b.1" "b.2"
2 | "1" -3.76702718583628 24.4136462889459
3 | "2" -0.330908658124268 0.319419137195124
4 | "3" -0.511690545434545 0.529664468534214
5 | "4" -0.305377768903184 0.265340116609954
6 | "5" -0.199927524776157 0.123721238940282
7 | "6" -0.316083996037225 0.260213398096244
8 | "7" -0.179011528508024 0.106972685117325
9 | "8" -0.0888637937494952 -0.028427327618115
10 | "9" -0.036762750819738 -0.0885704078117614
11 | "10" 0.014896296247314 -0.167047082101595
12 | "11" -0.00955688294957289 -0.0704870425495504
13 | "12" -0.026853147528161 -0.0706684577072335
14 | "13" 0.157378425786862 -0.333429836265337
15 | "14" 0.16081801933947 -0.379796412202317
16 | "15" 0.39651689609912 -0.692782733190456
17 | "16" 0.266837490801183 -0.562704346717075
18 | "17" 0.308839961086366 -0.572790943627429
19 | "18" 0.449326956029306 -0.673748600974233
20 | "19" 0.275773647849808 -0.505046292388746
21 | "20" 0.421888277606779 -0.63898569265957
22 | "21" 0.25826322818007 -0.508019941965192
23 | "22" 0.440199153857371 -0.711247477678718
24 | "23" 0.501016207922434 -0.746695970431095
25 | "24" 0.445603952861266 -0.658526520796573
26 | "25" 0.607197728663704 -0.876382243341869
27 | "26" 0.676343320714311 -0.942015480453174
28 | "27" 0.42218587227005 -0.643297646881319
29 | "28" 0.555638780509445 -0.820816479833321
30 | "29" 0.804087352731466 -1.14724217831347
31 | "30" 0.798378173712596 -1.22062314149758
32 | "31" 0.831229863185353 -1.19179593379434
33 | "32" 0.943863766657572 -1.34442938298365
34 | "33" 0.952190629733423 -1.35956781977824
35 | "34" 0.750528881316256 -1.0679819640179
36 | "35" 0.748242856859363 -1.08202596753564
37 | "36" 0.932729810245589 -1.33040974974771
38 | "37" 1.05807991427096 -1.54027274859282
39 | "38" 1.26146343096799 -1.79261594794855
40 | "39" 1.19201927855936 -1.71145310580102
41 | "40" 1.41118389029902 -1.86471595987861
42 | "41" 3.20125771882867 -4.23011743421596
43 | "42" 2.82669243126558 -4.05159659924356
44 | "43" 3.54356560438362 -4.98720191836787
45 | "44" 3.60797758514345 -5.21547396492233
46 | "45" 2.87626592116201 -4.32429091019314
47 | "46" 2.73242140931835 -3.92611303327406
48 | "47" 3.11539862251079 -4.40103639011333
49 | "48" 2.59309643400936 -3.67129947221722
50 | "49" 3.31879011163133 -4.67671814684814
51 | "50" 2.90867636851887 -4.16646233133314
52 | "51" 3.34794761903088 -4.58850038891941
53 | "52" 2.95672604349012 19.1160059747786
54 | "53" 0.69812006435304 -1.00984065355046
55 | "54" 1.02988137511636 -1.48216271811998
56 | "55" 2.33370165540426 -3.01617564060616
57 | "56" 3.51373417765162 -4.82032745063997
58 | "57" 3.29413139889997 -4.83257777093391
59 | "58" 2.87477330613713 -4.10664655404377
60 | "59" 3.41546585556104 -4.86449493814775
61 | "60" 3.57804842741808 -5.11385446274118
62 | "61" 3.5690112512764 -5.15608612905585
63 | "62" 3.53149641135467 -5.05322579753078
64 | "63" 3.25741848172401 -4.49227543235364
65 | "64" 3.56848710366705 -5.08464493935089
66 | "65" 3.44591249268458 -4.93174999353393
67 | "66" 2.92394519697462 -4.16214279633331
68 | "67" 2.80107780724362 -4.21984413607623
69 | "68" 2.72592654773748 -3.95658170257974
70 | "69" 3.00242578519425 -4.25204867271642
71 | "70" 2.67948399597818 -3.6991333226501
72 | "71" 3.21156240130913 -4.63575423283793
73 | "72" 2.8120499573847 -3.97834715374943
74 | "73" 2.83722960826487 -4.14103190059692
75 | "74" 3.13704689912762 -4.5825329093409
76 | "75" 3.32798144254644 -4.77332514394373
77 | "76" 3.65417958244769 -5.13187420314969
78 | "77" 3.76139612220749 -5.24265417837946
79 | "78" 2.89598152738604 -4.13249516173076
80 | "79" 3.45086230613618 -4.94228854677026
81 | "80" 3.45923063455081 -4.76934902141364
82 | "81" 3.76043231251799 -5.35079895513788
83 | "82" 3.15314865014458 -4.40816673492095
84 | "83" 3.31312094212158 -4.64360555628262
85 | "84" 3.14438696763222 -4.73697088303757
86 | "85" 3.24427422324745 -4.65507326325959
87 | "86" 3.8844093659635 -5.52620553307994
88 | "87" 3.23263983591075 -4.73229445398572
89 | "88" 3.47793516594894 -5.07295087314343
90 | "89" 3.45435384487567 -4.81393527699624
91 | "90" 3.41156130446507 -4.87953180904811
92 | "91" 3.3786243932368 -4.79432948308173
93 | "92" 3.16563449913953 -4.48555320574932
94 | "93" 3.62309168005375 -5.37690231061944
95 | "94" 3.15794793753484 -4.52621540282818
96 | "95" 2.95193808725801 -4.20635216162229
97 | "96" 3.52616816364843 -4.9432703803235
98 | "97" 2.89095090326005 -4.11132173359158
99 | "98" 3.18183962985639 -4.6233904302221
100 | "99" 2.92873481702184 -4.12543675406156
101 | "100" 2.91434911848177 -4.13177793194235
102 | "101" 2.87643003444141 -4.02636928190553
103 | "102" 2.85792998840149 -4.0581589818064
104 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_density.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_density.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_log.txt:
--------------------------------------------------------------------------------
1 | =============================================================
2 | Probit Bayesian Multiple Instance Classification
3 | =============================================================
4 | Start warming up 5000 MCMC samples!
5 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
6 | Finish warming up!
7 | -------------------------------------------------------------
8 | Start extracting 5000 MCMC samples!
9 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
10 | Finish MCMC sampling!
11 | =============================================================
12 | Elapsed time for chain1=5.401 mins: MCMC sampling is done!
13 | =============================================================
14 | Start warming up 5000 MCMC samples!
15 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
16 | Finish warming up!
17 | -------------------------------------------------------------
18 | Start extracting 5000 MCMC samples!
19 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
20 | Finish MCMC sampling!
21 | =============================================================
22 | Elapsed time for chain2=2.973 mins: MCMC sampling is done!
23 | Time difference of 8.377953 mins
24 | used (Mb) gc trigger (Mb) max used (Mb)
25 | Ncells 741552 39.7 1231381 65.8 1231381 65.8
26 | Vcells 1631565 12.5 8388608 64.0 8388583 64.0
27 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_psrf.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_psrf.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_trace.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_10000_Nwarm_5000_Nthin_100_trace.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_FDRs.txt:
--------------------------------------------------------------------------------
1 | "x"
2 | "1" 0.182873880082702
3 | "2" 0.0974107493134563
4 | "3" 0.0974107493134563
5 | "4" 0.0513490364025696
6 | "5" 0.0513490364025696
7 | "6" 0.0152646502835539
8 | "7" 0.0152646502835539
9 | "8" 0
10 | "9" 0
11 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_PSRF.txt:
--------------------------------------------------------------------------------
1 | "PSRF"
2 | "1" 1.02386503527593
3 | "2" 1.47915911620271
4 | "3" 5.82999171338443
5 | "4" 3.26218084075839
6 | "5" 2.56420475360549
7 | "6" 6.33606583247459
8 | "7" 2.14176000051596
9 | "8" 1.50576570331096
10 | "9" 1.08934724278367
11 | "10" 1.80471876279005
12 | "11" 1.01877170569363
13 | "12" 16.4362049415614
14 | "13" 5.73621746711375
15 | "14" 9.52795724158968
16 | "15" 2.12376068694462
17 | "16" 1.34316316721285
18 | "17" 5.70252548172438
19 | "18" 4.78154258884549
20 | "19" 3.41262034079643
21 | "20" 6.04202736408826
22 | "21" 2.4984779409575
23 | "22" 0.84145512102883
24 | "23" 0.985214626319024
25 | "24" 3.72063784464592
26 | "25" 2.91865625947731
27 | "26" 4.37325396421044
28 | "27" 0.834940207650178
29 | "28" 6.43549695635359
30 | "29" 0.847715998958725
31 | "30" 0.950928948483351
32 | "31" 1.01156090825791
33 | "32" 2.42934856428198
34 | "33" 4.14360308963723
35 | "34" 6.21119808610705
36 | "35" 5.64878911006462
37 | "36" 2.23928129869258
38 | "37" 0.892816076247788
39 | "38" 4.65410114367395
40 | "39" 0.860409953822797
41 | "40" 1.4461648217467
42 | "41" 1.96351246624193
43 | "42" 16.5803706552675
44 | "43" 0.874900058381902
45 | "44" 4.10845632960836
46 | "45" 4.18693727432315
47 | "46" 1.81203800085513
48 | "47" 2.46992385353592
49 | "48" 1.41966070194198
50 | "49" 60.4795368566264
51 | "50" 3.31756130920657
52 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_autocorr.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_autocorr.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_b.txt:
--------------------------------------------------------------------------------
1 | "b.1" "b.2"
2 | "1" -3.76702718583628 24.4136462889459
3 | "2" -0.906423885288549 1.36138792807225
4 | "3" -0.921964087779665 1.38571908636835
5 | "4" -0.786873929274974 1.18565579041132
6 | "5" -0.85572258735544 1.2909164857741
7 | "6" -0.913931859805252 1.35976501852876
8 | "7" -15.4984659219287 -19.1299767781713
9 | "8" -0.412269484513676 -1.11845080952541
10 | "9" -0.216565456825419 -1.37654681620883
11 | "10" -0.263584188087414 -1.29725610108867
12 | "11" -0.305103366238283 -1.19851221029916
13 | "12" -0.301034235397637 -1.21722417321951
14 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_beta.txt:
--------------------------------------------------------------------------------
1 | "beta.1" "beta.2" "beta.3" "beta.4" "beta.5" "beta.6" "beta.7" "beta.8" "beta.9" "beta.10" "beta.11" "beta.12" "beta.13" "beta.14" "beta.15" "beta.16" "beta.17" "beta.18" "beta.19" "beta.20" "beta.21" "beta.22" "beta.23" "beta.24" "beta.25" "beta.26" "beta.27" "beta.28" "beta.29" "beta.30" "beta.31" "beta.32" "beta.33" "beta.34" "beta.35" "beta.36" "beta.37" "beta.38" "beta.39" "beta.40" "beta.41" "beta.42" "beta.43" "beta.44" "beta.45" "beta.46" "beta.47" "beta.48" "beta.49" "beta.50"
2 | "1" -3.26233360705649 13.297992629225 12.724293214294 4.14641434456408 -15.3995004190371 -9.28567034713538 -2.9472044679056 -0.0576717274753696 24.0465338885795 7.6359346114046 -7.99009248989368 -11.4765700923635 -2.89461573688223 -2.99215117897316 -4.11510832795067 2.52223448156132 -8.91921127284569 4.35683299355719 -12.3753842192996 -2.24267885278309 3.77395645981701 1.33336360814841 8.04189509744908 -0.571067743838088 5.03607972233726 10.8576936214569 -6.9095383969683 -12.8459935387219 0.46726172188352 -2.35706556439501 -5.42888255010254 -4.33310317456782 -6.49471646796233 7.26750747385451 11.519117540872 9.92160365445798 -4.29513109491881 12.3830410085338 -2.79346281854269 17.5790308981071 5.60746090888056 -4.52783972553158 -8.32043296117832 -11.6657054708471 -10.655905803883 -15.63782051071 11.5653699715018 8.3204712857239 -2.27328691424755 2.66137361672105
3 | "2" -4.06740085361314 7.43136008192164 2.18956559155453 4.80707746565314 -4.18882178836091 -2.80669914964249 -0.340762437257507 1.20738701185738 7.13917235631122 2.99213808574779 -3.44886679915118 -4.21123879562038 -1.70159716861683 -2.77328637396938 -2.21739722241815 2.71681331784026 -4.84056975277478 3.88556199468717 -4.04748815945109 -1.39676866125326 -0.0668203167834147 -1.31045055960977 4.57849193288688 0.316022533727109 -1.69122473205368 2.75563638852571 -3.01377522789384 -4.29876168804463 -0.388646818883385 -3.40296831859154 -3.27560565877563 0.365599006726466 -0.198562861494998 2.62972719831701 4.30198119114378 2.0634820693574 -0.973582423843443 5.027777455555 -0.701909728672429 4.9933577869832 0.85206158172865 -0.574351268421146 -3.09986250241188 -3.21777553433983 -2.66068270227715 -4.68521618636546 4.77866655279618 2.94776697770464 -0.856368574225188 -1.03860094827233
4 | "3" -4.0032735870222 7.28660869363577 1.74831860907787 5.05936840766789 -3.82822799399057 -2.65788252103806 -0.364951555355298 1.2169180805743 6.85553948708152 3.16873950044673 -3.24060292649065 -4.06254775803923 -1.2725851008388 -2.6824846163035 -1.94814909002665 2.66142684563853 -4.71806338569717 3.88117568820725 -3.86975535399243 -1.59703165659858 -0.000201340799060559 -1.43852467195659 4.42011967858982 0.56151420300835 -1.59722213909827 2.57795739913782 -3.1254031565745 -4.02437408480505 -0.309224721596993 -3.24918181323653 -3.40523414351297 0.713073223362787 0.0589102844083928 2.42457971358584 4.1183619943138 2.21182817109789 -1.04990564053886 4.93598792342924 -0.687565679883454 4.87908203773796 0.868024001228279 -0.671674739375057 -3.1946642847665 -2.90127832497679 -2.32304623051189 -4.80911726570401 4.58435224865205 2.6395677903105 -0.913511110283572 -1.14154894711689
5 | "4" -3.76616339111353 7.18621171784737 1.87329910105855 4.92223826932555 -4.24623329581612 -2.47143378738635 -0.224948192571021 1.14733594086441 6.59733466271232 2.91040050490091 -3.03044304700244 -3.78877604361844 -1.29505637700066 -2.78304670577067 -1.76717384331247 2.4802631954831 -4.44488281838293 3.86454520983487 -3.66678688780611 -1.53142242718919 -0.301978847153957 -1.17924655032045 4.35529858185569 0.656983782086335 -1.82315113372403 2.62151819228858 -3.11634139294926 -3.84663358684916 -0.462592756914673 -3.30448504598428 -3.01864646668017 0.725454031708717 0.27806681234485 2.19966259018148 4.1353041749588 1.9674678275143 -0.801689534183025 4.70416759651498 -0.644967603765144 4.83396950017145 0.92347323619715 -0.684394770043292 -2.93917168352411 -2.97924533103832 -2.15966723722925 -4.55654399984662 4.53030950283085 2.76876779193398 -0.7895388545718 -1.47144292774888
6 | "5" -3.41737175646494 6.75451939618615 2.00186065442742 4.69218060615179 -4.05284260292726 -2.56989110496095 -0.212926498430677 0.992727122973725 6.56979192852534 3.0588574696581 -2.88590933582235 -3.90475715846458 -1.46288470889334 -2.8492160659336 -1.75455824909607 2.40420970551248 -4.45330213156857 3.57102777481844 -3.44872910477875 -1.42221939943069 -0.0540583632102764 -1.30783855500624 4.28449208293329 0.641046347945093 -1.73099359805167 2.46786724300307 -3.02268586474408 -3.60149759165673 -0.598546566883837 -3.11894989533068 -3.22055568771341 0.723835564804673 0.306307606903348 2.25350297102889 3.75680858113711 1.98653581099918 -0.93716602764251 4.60784626425269 -0.748601354496043 4.53486943496685 0.794015949850787 -0.656058683444413 -2.84717550078965 -3.01406522101549 -2.05635795160055 -4.90004628753499 4.6425292812349 2.66495110014147 -0.65788276970533 -1.32732261496367
7 | "6" -3.03564910040059 6.47680072864444 2.05417497699816 4.22664854389691 -4.21487652520027 -2.64586653250307 -0.366929623546608 0.90613194456031 6.48074884202852 2.93883236141456 -3.04338165377325 -3.84897074257721 -1.19706230402781 -2.57247268281589 -1.67805594781869 2.50002869050226 -4.46824499716081 3.47596495022255 -2.94268619532057 -1.29206401146576 -0.174568772658874 -1.13349510000844 4.64014029966807 0.624121816116547 -1.50517652039662 2.07747092584307 -2.922990015375 -3.70037694853634 -0.606125920611074 -3.40235135026017 -3.29471291140252 0.487112219283824 0.593476576838754 2.14755335896995 3.73566453951933 1.92564790711435 -0.784170419222634 4.41408311817003 -0.624579059415306 4.19779175111765 0.615518804184671 -0.629621911044145 -2.72469381730912 -2.65280605868693 -2.06134421776304 -4.43557757594147 4.33964381875847 2.62133501642519 -0.672866247631701 -1.37704614289813
8 | "7" -6.59497648033298 4.75562383912244 -10.8391362697221 -13.5915772390656 -6.35049882156576 3.40258439207627 14.5332314145929 -0.240574217785743 11.6758489437429 15.7248740249392 -4.45270242904529 12.1066786409617 7.6616266145203 -1.70718406321337 -21.8878692584293 9.8224639233288 20.6825663580947 3.83601891205152 4.1727610574749 9.45470397221016 4.1556066725999 3.26818885187556 6.24579998436217 10.6499001388578 -20.7374512475596 -2.9048855022532 -7.33639665372785 11.1411319493922 -1.07917234079093 -10.2122980222135 -7.80118846491077 6.13233703843046 2.00837532271306 -5.13974588650843 3.34299828563353 21.0719249606882 -5.670606924487 -1.82419239101149 -1.10973291801855 9.74996834668103 -14.6540594602015 3.70550266113916 -15.752024011353 0.224640639532451 0.204659873116357 -8.89363249180663 7.06796606927189 2.42209247063156 3.27014742801438 0.946942018182229
9 | "8" -3.46368698846399 7.39330392749322 -5.20077486018303 -1.13251097035599 0.482129847954619 1.80308210947859 2.07076407499441 0.966793579607081 5.50144458549438 6.21176749853968 -2.42974820978759 5.80768163006545 2.4188225047227 4.54512383188407 -6.05734767628651 -2.55825465746228 4.61631513911306 1.51288567999944 0.317611932023413 4.1587068577562 2.23826882422181 -1.820344271933 4.83809391080374 3.52845221410307 -7.72847993998893 -2.58293159622297 -3.27315115250316 3.31977316532135 -0.352941338668369 -3.05927073667505 -1.6816061968644 1.7460675391476 2.87157765922681 -1.26635307323491 -2.6609969093638 8.86378961876503 -0.78952646077862 0.377218064194308 -1.5439969122265 3.00098955059571 -1.85639413719456 4.26065050549239 -0.160248183291826 1.5545822544548 1.12727197349473 -0.86359095079082 0.401511524221312 2.28474224187792 3.66025482257984 2.08550584357876
10 | "9" -3.86975734070748 6.8344006400137 -4.93169521476699 -0.360001592999082 1.12981274021296 1.3985529127455 2.05999016938319 0.979069596855295 6.12422802089918 6.20570117177266 -3.2554814514966 6.3828799461417 2.01161613215789 4.36960175010831 -6.13637236609121 -2.3608719455613 4.45855615078689 1.2796839118064 -0.974763756089335 3.04469106362538 2.24822657045217 -1.6147894014361 3.5880678187082 3.56559573563976 -6.08209898131101 -1.35216286559084 -2.93320425991056 3.62144133293953 -0.187449453907692 -3.21578344961378 -2.15643038139834 1.54478070341307 3.28284131733284 -0.811151937033555 -2.85638168375524 8.56252991301609 -1.21774226952222 1.00806219321593 -0.895691669710019 1.82792110588041 -1.52793908876202 3.84667795009841 -0.259747380555426 1.73996280601345 1.90960135107111 -0.750278082617047 0.137481321976773 2.49645626081311 3.50087331004385 1.68769284126251
11 | "10" -3.45939521697041 6.37055927131472 -4.46878183462199 -0.0186723543671512 1.82972788813465 1.17553659094491 2.02421890975894 0.451273943739319 5.41391014629735 5.81759534317716 -3.41667880448291 6.75132688821808 1.56822978484456 4.22511140351813 -5.67449789453435 -2.67102155039358 4.26732068627551 2.05504616295346 -0.33966787769472 2.62749721772552 1.84088990847951 -1.93824599284806 3.7449512347243 4.04729427926078 -5.84830021916227 -0.898450119537031 -2.85339639563637 2.51940916017535 0.479648728619296 -2.53977687520801 -2.13864590967629 1.38563028528022 3.73190641127479 -0.608310786789784 -3.00539710134058 7.22609157533746 -1.131429608634 0.805989198618881 -0.429792645427008 0.926146412898215 -1.2996780516777 4.0818185973231 0.335976574815282 0.987946025848874 2.0170557981447 -0.294039207462457 0.604443638648396 1.99224854837581 4.27478624197796 1.56488564101336
12 | "11" -3.77229953685205 6.3746163669353 -4.27896287127234 0.540461719676415 1.40626114123685 1.19557786951385 2.21037277997303 0.427661198070244 5.32874523223065 5.09218018782212 -3.2955229911704 6.50877704568082 1.59215045759359 3.20534394593929 -5.91216802994553 -2.18903303121344 4.57196082595811 2.49361852160088 -0.546486225709063 1.9631681994638 2.28690685312999 -2.18266456909487 4.09011696728845 3.16767727636963 -5.63493694042822 -1.04484083261326 -3.01784849377623 2.37825021466161 -0.196229401462199 -2.57108423831522 -1.09116683825654 2.35533735062831 4.11358430377903 -1.31195211991318 -3.13427042349547 6.16839989817657 -1.65899704171255 1.5850162179398 -0.967352739689489 0.910032850363366 -0.579920867470927 4.2791171570531 -0.213241280999973 0.173177214982784 2.18819672632549 -0.172449813770349 1.0170110222181 1.87628021640341 4.47382214825757 1.29274789238657
13 | "12" -3.23228942144096 5.93619263342629 -3.73712834608557 0.205737047570176 1.57993100954719 1.34467613106663 1.85755122561726 0.0776659065453137 4.99796501693335 5.42894557076269 -2.26793654895396 6.26329821176938 1.7397161821547 2.91794594248927 -4.93710295899544 -2.23299386367809 4.02773920438443 2.49258873945274 -0.760514908904588 1.75074926724913 1.86417926684271 -1.79116516720357 4.44738945195126 2.60333619064707 -4.62658136040609 -0.583882508194581 -3.16101393483766 2.65158902740378 -0.185931470098708 -2.41804634917161 -1.17593642776115 2.21865069673999 4.08731444768869 -1.79725362401997 -3.65069502796657 6.19648410729555 -1.13673187404381 1.70806943848796 -0.482580729563417 0.236465976465666 -0.846326068019793 3.51102378562029 -0.334562136901343 0.989537025694749 2.33758368035919 -0.774344943857742 0.715526310773029 2.26717920923956 4.07078675770844 1.52900311389766
14 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_density.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_density.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_log.txt:
--------------------------------------------------------------------------------
1 | =============================================================
2 | Probit Bayesian Multiple Instance Classification
3 | =============================================================
4 | Start warming up 500 MCMC samples!
5 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
6 | Finish warming up!
7 | -------------------------------------------------------------
8 | Start extracting 500 MCMC samples!
9 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
10 | Finish MCMC sampling!
11 | =============================================================
12 | Elapsed time for chain1=0.819 mins: MCMC sampling is done!
13 | =============================================================
14 | Start warming up 500 MCMC samples!
15 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
16 | Finish warming up!
17 | -------------------------------------------------------------
18 | Start extracting 500 MCMC samples!
19 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
20 | Finish MCMC sampling!
21 | =============================================================
22 | Elapsed time for chain2=0.712 mins: MCMC sampling is done!
23 | Time difference of 1.533468 mins
24 | used (Mb) gc trigger (Mb) max used (Mb)
25 | Ncells 741552 39.7 1231381 65.8 1231381 65.8
26 | Vcells 1626884 12.5 8388608 64.0 8388389 64.0
27 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_psrf.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_psrf.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_trace.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_1000_Nwarm_500_Nthin_100_trace.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_FDRs.txt:
--------------------------------------------------------------------------------
1 | "x"
2 | "1" 0.554990088441598
3 | "2" 0.479135541008856
4 | "3" 0.403287654320988
5 | "4" 0.335112972033497
6 | "5" 0.272121585541179
7 | "6" 0.213573391973612
8 | "7" 0.157928068803753
9 | "8" 0.101104651162791
10 | "9" 0.0456783216783217
11 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_PSRF.txt:
--------------------------------------------------------------------------------
1 | "PSRF"
2 | "1" 1.0822358030091
3 | "2" 1.00586139791624
4 | "3" 1.03964902896681
5 | "4" 1.06326939539812
6 | "5" 0.999498844042964
7 | "6" 1.05586815083901
8 | "7" 1.23195874856276
9 | "8" 1.33420178846774
10 | "9" 1.11757883255968
11 | "10" 1.00762154230783
12 | "11" 0.990104203365064
13 | "12" 1.03192844376647
14 | "13" 1.0391457799325
15 | "14" 1.11556836704477
16 | "15" 1.22792962344341
17 | "16" 1.04990138100632
18 | "17" 1.05455866401551
19 | "18" 1.1791514229302
20 | "19" 0.990131908644186
21 | "20" 1.17326170720425
22 | "21" 1.48999469027837
23 | "22" 1.10428758019909
24 | "23" 1.09241166206231
25 | "24" 1.2090760504587
26 | "25" 1.08766506498875
27 | "26" 1.02988389109466
28 | "27" 1.03251985788978
29 | "28" 1.30480195985575
30 | "29" 1.29043739556727
31 | "30" 1.04571496431058
32 | "31" 1.11969859334826
33 | "32" 1.16406880404301
34 | "33" 1.19889059271726
35 | "34" 1.14707921296032
36 | "35" 1.03696580051465
37 | "36" 1.05333878761689
38 | "37" 1.12262018783641
39 | "38" 0.996490513763428
40 | "39" 1.01901003554801
41 | "40" 1.00321021394275
42 | "41" 1.17753804825294
43 | "42" 1.04401273392488
44 | "43" 1.2202463484597
45 | "44" 1.04599192056149
46 | "45" 1.23472649914739
47 | "46" 1.01268070364168
48 | "47" 1.36909176361834
49 | "48" 1.15074665593458
50 | "49" 1.02533063287499
51 | "50" 1.14746005938395
52 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_autocorr.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_autocorr.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_b.txt:
--------------------------------------------------------------------------------
1 | "b.1" "b.2"
2 | "1" -3.76702718583628 24.4136462889459
3 | "2" 3.30383214707302 -4.53219207477923
4 | "3" 3.4180403845578 -4.8368096515551
5 | "4" 3.31968282984512 -4.60110634893136
6 | "5" 3.47296689912016 -4.85574103736857
7 | "6" 3.11420437260209 -4.45694176526191
8 | "7" 2.87419360206603 -4.23611164614966
9 | "8" 2.95828830785843 -4.29216843892478
10 | "9" 3.84628976672782 -5.38287430475209
11 | "10" 3.53333745728849 -5.20372321544333
12 | "11" 3.14142677113371 -4.45537042371164
13 | "12" 2.69717860582028 -3.80992101913535
14 | "13" 2.85164105635384 -4.04455402513612
15 | "14" 3.45869793322493 -4.83203697844639
16 | "15" 2.90982283583299 -4.08113774091198
17 | "16" 3.15537783424335 -4.54385750523637
18 | "17" 2.76910830774524 -4.08872905670624
19 | "18" 2.94605311225287 -4.26465397067609
20 | "19" 2.93725590603116 -4.30721350128817
21 | "20" 3.05439601916785 -4.36797421337498
22 | "21" 3.76463175794115 -5.36914151747415
23 | "22" 3.47881791679779 -4.76973152893631
24 | "23" 3.71336521211178 -5.10756963575926
25 | "24" 3.61022108866657 -5.2740775600999
26 | "25" 3.06816745881187 -4.42941211997906
27 | "26" 3.20915098736819 -4.56620871790847
28 | "27" 2.84684018630459 -4.12570480349818
29 | "28" 3.40907429071212 -4.89638656252853
30 | "29" 3.29245736997763 -4.58794861154328
31 | "30" 3.22169676927172 -4.62749492766856
32 | "31" 3.05473302755464 -4.26390452570814
33 | "32" 2.80545518151306 -4.08145982660572
34 | "33" 3.67557715776584 -5.17431288519918
35 | "34" 3.61506368553027 -5.10153709612816
36 | "35" 3.02448451933726 -4.21926031774081
37 | "36" 2.62502896938419 -3.74450924910255
38 | "37" 2.86704088787218 -4.18376788255469
39 | "38" 3.22466084413347 -4.49699730369187
40 | "39" 3.37224793972868 -4.84337663750945
41 | "40" 4.01303072649433 -5.60074745085821
42 | "41" 3.45731028798984 -5.0193106211904
43 | "42" 2.44703460073495 -3.60478463657011
44 | "43" 3.86345244478014 -5.18459433025694
45 | "44" 3.31614945965634 -4.72963701289226
46 | "45" 3.6729721790873 -5.06102966595437
47 | "46" 3.09383863309589 -4.31141304412634
48 | "47" 3.4945747182404 -4.81394841822547
49 | "48" 3.92013344488785 -5.56725022286761
50 | "49" 3.03481190450064 -4.2850274431403
51 | "50" 2.63505142038331 -3.76112685874074
52 | "51" 2.28588232284465 -3.34661469115502
53 | "52" 2.82459487421018 -3.97694836372885
54 | "53" 3.29792670200567 -4.97554444328497
55 | "54" 3.56094097813231 -4.91721182279955
56 | "55" 3.91556732985337 -5.54630272610527
57 | "56" 2.47148199661745 -3.5180681074422
58 | "57" 3.12573627464127 -4.37609280832399
59 | "58" 3.02290111499462 -4.34558644408605
60 | "59" 3.35571284047488 -4.91863617493902
61 | "60" 3.09920673631166 -4.48750198942301
62 | "61" 3.56057224404001 -5.04473646862245
63 | "62" 3.47785839117949 -4.95532186039136
64 | "63" 3.5720328140968 -4.94653586758159
65 | "64" 3.59811870813865 -4.86268186022628
66 | "65" 3.18166042128232 -4.36045566507928
67 | "66" 3.15709901163835 -4.3845488871211
68 | "67" 3.13924255336627 -4.54771109266146
69 | "68" 3.09221425670396 -4.36977680791491
70 | "69" 3.44835407982502 -4.74095366011322
71 | "70" 3.50833457407028 -5.10325975494472
72 | "71" 3.14174483362357 -4.54846850500724
73 | "72" 3.77487295356363 -5.36294986015075
74 | "73" 3.11028847625563 -4.46702922567275
75 | "74" 3.29901680357991 -4.56837815157151
76 | "75" 3.48966825063259 -5.00229187167727
77 | "76" 2.75505884929848 -3.98590477317245
78 | "77" 3.04430661205525 -4.28525513849218
79 | "78" 3.0850556346573 -4.20239353254402
80 | "79" 3.2518455280482 -4.6387145333127
81 | "80" 3.49572320415769 -4.82491905966158
82 | "81" 2.67328393537986 -3.95241770376289
83 | "82" 3.50165307287943 -4.83120910714248
84 | "83" 3.62453186036724 -5.07611017739882
85 | "84" 2.29306768606385 -3.19216229716355
86 | "85" 3.29349891050549 -4.54921219833909
87 | "86" 3.00224521360976 -4.15181839922395
88 | "87" 3.06520262113402 -4.27038258339833
89 | "88" 2.89754938173036 -4.21187152605142
90 | "89" 3.50685804545355 -4.98627362211758
91 | "90" 3.34569425858335 -4.82796593654709
92 | "91" 3.07430938051155 -4.41954225937349
93 | "92" 3.28332802842828 -4.7093929813139
94 | "93" 3.654296453656 -5.13160887959311
95 | "94" 2.88881608261092 -4.26566683563124
96 | "95" 3.28761973112332 -4.46252224914738
97 | "96" 3.86530651841471 -5.53235594615778
98 | "97" 3.56029152242014 -5.05664157231338
99 | "98" 3.66149750209421 -5.20812383693507
100 | "99" 3.61893495944532 -5.22071893664653
101 | "100" 3.06681979703862 -4.53669185138719
102 | "101" 3.51374276830277 -4.82111354861198
103 | "102" 3.35742697662368 -1.13014010631856
104 | "103" 0.315233847336906 -0.936584635048904
105 | "104" 0.276434315343732 -0.890805810635041
106 | "105" 0.20929812474924 -0.776607216138546
107 | "106" 0.258459463867907 -0.869138069149338
108 | "107" -0.00344094777620424 -0.557492537568035
109 | "108" 0.273326221506484 -0.888648595168477
110 | "109" 0.3776979844355 -0.990579318895862
111 | "110" 0.200409128657177 -0.801861507630405
112 | "111" 0.441208890420033 -1.09072446870403
113 | "112" 0.348321014953894 -0.965094766102888
114 | "113" 0.459045757010984 -1.11398481355049
115 | "114" 0.201550588450564 -0.777718513006395
116 | "115" 0.370388569291056 -1.02941023603424
117 | "116" 0.284375653194524 -0.848263731969767
118 | "117" 0.293306044490861 -0.908365316680651
119 | "118" 0.30954357577125 -0.91653391179932
120 | "119" 0.400076316374316 -1.01235688679722
121 | "120" 0.565049837128903 -1.22427201169531
122 | "121" 0.574811009291466 -1.17678143465765
123 | "122" 0.631269608930857 -1.28035352939433
124 | "123" 0.592041896487582 -1.26050700802949
125 | "124" 0.537901878134188 -1.17268910938877
126 | "125" 0.778369322682399 -1.45809480171047
127 | "126" 0.879920318940754 -1.53974688593239
128 | "127" 0.671943574087661 -1.27983237459864
129 | "128" 0.701606001369774 -1.32980942353875
130 | "129" 0.762759090440326 -1.43901757710702
131 | "130" 0.715147392599417 -1.32590154131922
132 | "131" 0.597309187887022 -1.15057604968152
133 | "132" 0.689144596810062 -1.30206680066437
134 | "133" 0.995685547241525 -1.56666873038523
135 | "134" 0.74514881417936 -1.3908128813122
136 | "135" 0.808945512519431 -1.42126073234586
137 | "136" 0.75136549401175 -1.27179854256302
138 | "137" 0.998081038252195 -1.62627507279196
139 | "138" 0.715847876552653 -1.31785929899449
140 | "139" 0.606267317289499 -1.1578951080058
141 | "140" 0.802879468357257 -1.30574339737151
142 | "141" 0.877998893597745 -1.368449033998
143 | "142" 0.958667380469495 -1.4416546486301
144 | "143" 2.51925584706797 -3.52940981012708
145 | "144" 3.66497007435543 -5.20491153895714
146 | "145" 3.3344473506961 -4.61907338526048
147 | "146" 3.42843548373501 -4.89172122959637
148 | "147" 3.54241289962721 -5.12824999626197
149 | "148" 3.45602674425321 -4.80420113545079
150 | "149" 3.03415956818872 -4.46161472828478
151 | "150" 3.54585029885878 -5.00254326236318
152 | "151" 3.06866016855063 -4.22462894211146
153 | "152" 2.74603480850741 -3.87829380414597
154 | "153" 3.64660764612753 -5.07519274522268
155 | "154" 3.24385692880156 -4.46670937729213
156 | "155" 3.29372615756778 -4.84097314587422
157 | "156" 3.23321104104927 -4.64821840760508
158 | "157" 2.74444849289172 -3.89728744383371
159 | "158" 2.66000418740304 -3.6943313507671
160 | "159" 2.53046223074388 -3.52322121575651
161 | "160" 3.26800661552158 -4.44467871813825
162 | "161" 2.90900184366232 -4.11309523517358
163 | "162" 2.96339663588646 -4.26366971736162
164 | "163" 3.13671482503352 -4.68139438796369
165 | "164" 3.30895876839657 -4.67924417973862
166 | "165" 3.41528131198128 -4.67822477598138
167 | "166" 3.6789875442325 -5.24732322348794
168 | "167" 2.93284873238089 -4.47232912777023
169 | "168" 3.44546876810775 -4.93344218130814
170 | "169" 3.60009719927279 -4.87695157592447
171 | "170" 3.04270140677031 -4.19471497405923
172 | "171" 3.82600774318516 -5.17481247163057
173 | "172" 3.28235268135773 -4.63959993406344
174 | "173" 3.69439244685131 -5.18412971161057
175 | "174" 3.14763630239373 -4.42191833076887
176 | "175" 3.38060872762306 -4.85445885266854
177 | "176" 3.43006001880501 -5.01679878478421
178 | "177" 3.32066931015511 -4.63190013420214
179 | "178" 2.70561943993262 -3.91461674372366
180 | "179" 3.11873109601629 -4.37829648761408
181 | "180" 3.49109283153044 -4.78990140410815
182 | "181" 3.30821250388801 -4.50848112302513
183 | "182" 2.94287348543707 -4.06097224415397
184 | "183" 3.07022679647243 -4.2302108364216
185 | "184" 3.35716274854555 -4.63775066766529
186 | "185" 3.36609477741947 -4.84698247029447
187 | "186" 3.13532986958774 -4.42769911001416
188 | "187" 2.8605241632058 -4.29927795171398
189 | "188" 3.45229194139133 -4.9942787898797
190 | "189" 3.08929065907886 -4.34364381879367
191 | "190" 3.35518860418381 -4.69041413701582
192 | "191" 3.56778742143925 -5.04734967090294
193 | "192" 3.45170243177872 -4.84556181208258
194 | "193" 3.64288327008305 -5.12098022977453
195 | "194" 2.91222257190051 -4.0293568670716
196 | "195" 3.04472370005133 -4.33955691100964
197 | "196" 2.61339362449259 -3.64767018614205
198 | "197" 3.13489274576875 -4.2831675326632
199 | "198" 4.1444354841293 -5.66579309263532
200 | "199" 3.75439682858194 -5.17783634470198
201 | "200" 3.18822240272405 -4.48355518994932
202 | "201" 3.78254799547999 -5.35281730513178
203 | "202" 3.51532660778702 -4.84796128528369
204 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_density.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_density.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_log.txt:
--------------------------------------------------------------------------------
1 | =============================================================
2 | Probit Bayesian Multiple Instance Classification
3 | =============================================================
4 | Start warming up 10000 MCMC samples!
5 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
6 | Finish warming up!
7 | -------------------------------------------------------------
8 | Start extracting 10000 MCMC samples!
9 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
10 | Finish MCMC sampling!
11 | =============================================================
12 | Elapsed time for chain1=8.347 mins: MCMC sampling is done!
13 | =============================================================
14 | Start warming up 10000 MCMC samples!
15 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
16 | Finish warming up!
17 | -------------------------------------------------------------
18 | Start extracting 10000 MCMC samples!
19 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
20 | Finish MCMC sampling!
21 | =============================================================
22 | Elapsed time for chain2=3.719 mins: MCMC sampling is done!
23 | Time difference of 12.06885 mins
24 | used (Mb) gc trigger (Mb) max used (Mb)
25 | Ncells 741552 39.7 1231381 65.8 1231381 65.8
26 | Vcells 1636765 12.5 10146329 77.5 10146200 77.5
27 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_psrf.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_psrf.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_trace.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_20000_Nwarm_10000_Nthin_100_trace.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_FDRs.txt:
--------------------------------------------------------------------------------
1 | "x"
2 | "1" 0.217080658665922
3 | "2" 0.172792792792793
4 | "3" 0.130646992054484
5 | "4" 0.09652113411028
6 | "5" 0.0619263456090652
7 | "6" 0.0343003064351379
8 | "7" 0.0150306748466258
9 | "8" 0.00426617203802458
10 | "9" 0
11 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_PSRF.txt:
--------------------------------------------------------------------------------
1 | "PSRF"
2 | "1" 4.00128330457526
3 | "2" 20.193216958998
4 | "3" 12.4066318346222
5 | "4" 1.32419952004832
6 | "5" 4.52014982236135
7 | "6" 4.71689560947989
8 | "7" 2.80791814046192
9 | "8" 0.925418220376477
10 | "9" 4.00460578210725
11 | "10" 1.58877840973407
12 | "11" 2.09102412276539
13 | "12" 2.50474004709707
14 | "13" 24.9804687990814
15 | "14" 2.41213137050192
16 | "15" 11.0970466412037
17 | "16" 7.7435278119961
18 | "17" 0.975151976478427
19 | "18" 132.581453347922
20 | "19" 0.985669783206082
21 | "20" 0.996911792361477
22 | "21" 1.6644843144977
23 | "22" 1.08438428493391
24 | "23" 0.919350306163082
25 | "24" 55.3559009750345
26 | "25" 1.14884303977295
27 | "26" 1.67512431599686
28 | "27" 5.33248276774966
29 | "28" 0.962239823339898
30 | "29" 4.6467612285725
31 | "30" 7.1761004227781
32 | "31" 10.5691550880424
33 | "32" 4.81691999058328
34 | "33" 1.35248068469473
35 | "34" 1.79403221100691
36 | "35" 1.3783740682839
37 | "36" 0.985151078406352
38 | "37" 0.926425226558782
39 | "38" 1.01915176532262
40 | "39" 1.62944667005353
41 | "40" 2.29477338240559
42 | "41" 3.07574743918023
43 | "42" 1.01154762108293
44 | "43" 12.1097757474422
45 | "44" 6.60043129626054
46 | "45" 0.925597005440362
47 | "46" 3.82901591627406
48 | "47" 0.910634410360886
49 | "48" 5.70922004718465
50 | "49" 0.966079962441366
51 | "50" 7.46941779590046
52 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_autocorr.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_autocorr.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_b.txt:
--------------------------------------------------------------------------------
1 | "b.1" "b.2"
2 | "1" -3.76702718583628 24.4136462889459
3 | "2" -0.861282923595782 1.26709117244432
4 | "3" -0.785534089555031 1.16691959044953
5 | "4" -0.821301736647929 1.25020914503084
6 | "5" -0.827654667789829 1.21480897190612
7 | "6" -0.79238026599925 1.22055047872609
8 | "7" -0.910119991740104 1.29936464700733
9 | "8" -0.726744947784511 1.09026617162922
10 | "9" -0.826028427440964 1.14014139669243
11 | "10" -0.806964667663992 1.18265879471686
12 | "11" -0.760666196664565 1.08032095005704
13 | "12" 2.9033116637805 -4.38414568375488
14 | "13" -0.340071611829184 -0.449303505947896
15 | "14" -0.425388555325367 -0.33676261412271
16 | "15" -0.24878360031333 -0.54286670238236
17 | "16" -0.356277452370039 -0.393461596720537
18 | "17" -0.322069215698581 -0.418560485220598
19 | "18" -0.270817664159416 -0.515156224875517
20 | "19" -0.301879452687639 -0.47417011277728
21 | "20" -0.277394622559251 -0.481198726696633
22 | "21" -0.39514070483375 -0.342205683253956
23 | "22" -0.384185901564269 -0.359870287739554
24 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_beta.txt:
--------------------------------------------------------------------------------
1 | "beta.1" "beta.2" "beta.3" "beta.4" "beta.5" "beta.6" "beta.7" "beta.8" "beta.9" "beta.10" "beta.11" "beta.12" "beta.13" "beta.14" "beta.15" "beta.16" "beta.17" "beta.18" "beta.19" "beta.20" "beta.21" "beta.22" "beta.23" "beta.24" "beta.25" "beta.26" "beta.27" "beta.28" "beta.29" "beta.30" "beta.31" "beta.32" "beta.33" "beta.34" "beta.35" "beta.36" "beta.37" "beta.38" "beta.39" "beta.40" "beta.41" "beta.42" "beta.43" "beta.44" "beta.45" "beta.46" "beta.47" "beta.48" "beta.49" "beta.50"
2 | "1" -3.26233360705649 13.297992629225 12.724293214294 4.14641434456408 -15.3995004190371 -9.28567034713538 -2.9472044679056 -0.0576717274753696 24.0465338885795 7.6359346114046 -7.99009248989368 -11.4765700923635 -2.89461573688223 -2.99215117897316 -4.11510832795067 2.52223448156132 -8.91921127284569 4.35683299355719 -12.3753842192996 -2.24267885278309 3.77395645981701 1.33336360814841 8.04189509744908 -0.571067743838088 5.03607972233726 10.8576936214569 -6.9095383969683 -12.8459935387219 0.46726172188352 -2.35706556439501 -5.42888255010254 -4.33310317456782 -6.49471646796233 7.26750747385451 11.519117540872 9.92160365445798 -4.29513109491881 12.3830410085338 -2.79346281854269 17.5790308981071 5.60746090888056 -4.52783972553158 -8.32043296117832 -11.6657054708471 -10.655905803883 -15.63782051071 11.5653699715018 8.3204712857239 -2.27328691424755 2.66137361672105
3 | "2" -3.09803176809922 6.24504557171588 1.96427757262907 3.94113152482288 -4.33195046163583 -2.62754168722857 -0.326361106671179 0.848328289615637 6.34179853066547 3.14537506373186 -2.73144543682889 -3.82423513919143 -1.3084631578303 -2.57622666898693 -1.42207500745869 2.45493529874528 -4.4722452051035 3.46574475628175 -3.10511512760194 -1.16175561882882 0.0326483885479983 -0.95750764508209 4.84358073511622 0.693038660374529 -1.56223727217638 1.94697682692955 -3.05035349078913 -3.44567685320677 -0.673742383179571 -3.22671840055949 -3.20370485566632 0.259444530137439 0.715858243351383 2.23688824680762 3.73556389843634 2.12743993920955 -0.633765248321811 4.05616472399749 -0.436964705444274 4.13962710940134 0.515842817495858 -0.799506765718329 -2.58324418157125 -2.56061830145301 -2.21582631673404 -4.28377247760966 4.06469664376891 2.67081268616586 -0.595540516399658 -1.05723352439165
4 | "3" -2.81057533836941 6.19101898346699 1.73089082045029 3.64481344846696 -3.90322220952603 -2.5454509511065 -0.0287643722194485 1.1409796162019 6.26984905079421 2.88239672631643 -2.9890652339318 -3.70573604715088 -1.482545892379 -2.3783873495304 -1.39071664039762 2.2967927029148 -4.51842712443883 3.19565960727899 -3.26421783034066 -1.13770251371045 0.203012836054067 -0.871019401613785 4.6036618776112 0.776978624120441 -1.73978327344027 2.17930226380217 -2.32851763340348 -3.18820149468107 -0.755501882362101 -3.18444773023567 -3.15566763998935 0.308941640013121 0.787098650342631 2.12772813157725 3.62831673309507 1.94444380908285 -0.597535921567084 3.84735572984035 -0.574624438049699 4.20630829338213 0.417820886992001 -0.740243317988769 -2.58977375401617 -2.37837668320284 -2.1364811852983 -4.07120177480766 3.78242984129068 2.51784962149114 -0.786007326511402 -0.653825909845905
5 | "4" -3.00046975629381 6.36066848156118 1.58311658547083 3.4072618140791 -3.63101232933272 -2.33634128661288 -0.212843411147336 0.946507222037513 6.01250519283852 2.83605259432799 -2.89418908090074 -3.37435142824366 -1.462991991556 -2.20563837001389 -1.17520450491933 2.46257046337501 -4.1525623969 3.19687222149245 -3.15512044291687 -1.29282433074845 -0.0799823941600589 -0.715007221230242 4.28972682982036 0.42206698368894 -1.86276114990071 2.00541646246966 -2.09543256408377 -3.40619989842588 -0.63824369223067 -3.05284407634521 -2.88981654231455 0.323391116813675 0.650420486690791 1.82851239736478 3.34128262275589 2.13422872356694 -0.673702643771796 3.61401169995146 -0.76138719742965 4.26403210217135 0.387745083854497 -0.643195631606542 -2.41348410263832 -2.12897804255644 -2.12076043913828 -4.04147348514584 3.70442575680946 2.41634512277415 -0.888588502620473 -0.930443510561945
6 | "5" -2.87932890015214 5.97082016408305 1.60685782648874 3.68626960959619 -3.69625410429515 -2.28407442398479 -0.0996800286555741 0.908268869197725 5.57342481439536 3.02067014583235 -2.32445855660232 -3.26086290301774 -1.13047521064469 -2.34226852212067 -1.09194272920956 2.29234976092197 -3.75809253503769 3.11952003378766 -2.86193867646879 -1.00922570124045 -0.122023942121522 -0.69908131367767 4.52381192310239 0.845174795639466 -1.96759460753572 2.0251309474565 -2.52230112068113 -3.1176461783397 -0.569847819202359 -2.95026774008641 -2.61915179083035 0.424114808220978 0.653068533330788 1.77810515019572 3.16582011017846 2.02541670143241 -0.611438423803207 3.52457297604256 -0.44521032321415 3.85958753171845 0.323076603792961 -0.912276349330257 -2.72060387804546 -1.93750662604808 -2.0377319288867 -4.12869143491986 3.43344714331536 2.31505719973048 -0.860893278242402 -0.87489811352645
7 | "6" -2.9439122889741 5.70803078277339 1.38450249903033 3.57018966104149 -3.09638516242704 -2.21257523870215 0.125359583488415 0.715541506852319 5.72443598353384 2.8214118949648 -2.3111785558574 -3.22485689279183 -1.02234393235494 -2.12322975464422 -1.02263313929445 2.39409140030115 -3.68942442616028 2.94790700384275 -2.81892642463378 -0.986922041525236 -0.266888130725683 -0.817038179251835 4.17917988093502 0.833593191823658 -2.0383486982432 2.18610661635106 -2.21276817049227 -2.99387612960805 -0.501855947612778 -3.0120063968337 -2.36499764512759 0.286637569829976 0.655501910782813 1.78970722547637 2.93155010802447 1.97330577007582 -0.66847412862637 3.49433921387164 -0.565789996903614 3.71678235234309 0.219911379793812 -0.978314616607687 -2.81974871417587 -2.03769341550948 -1.89737654620225 -3.94933453973814 3.69935778220349 2.26040156931659 -0.997416220984556 -0.888839245289442
8 | "7" -2.7890751819209 5.62266703767917 1.0711557392131 3.61890286164243 -3.18924477253084 -2.22429256863503 -0.0798150218859209 0.606733776682273 5.5981498450288 2.60680106046523 -2.22136435554259 -3.06323708437541 -0.965976713136635 -2.0343468566891 -0.788083077012144 2.26272427904602 -3.53020511707001 2.94010980180236 -2.64742088788135 -0.816949698187065 -0.2369169467278 -0.829740648485668 3.80350913418112 0.805282505293591 -2.03859171085959 2.05091828967405 -2.52852168102986 -2.9591543288763 -0.420094362848037 -2.80511805151446 -2.38578462993357 0.257726259079912 0.513878007177344 1.78102727612655 2.76026263592608 1.81486473697234 -0.604659792514767 3.5618674946752 -0.698471234112254 3.74430329406394 0.177758959089463 -1.08153181073799 -2.75127384110454 -2.06151317532654 -2.04980133377993 -4.06828126963416 3.54383986526901 2.14686435083699 -0.888282120130337 -1.10847909249241
9 | "8" -3.1114398706384 5.70830532576712 0.97574496975144 3.60239845335019 -3.28835785349213 -2.12003633786782 -0.0532406245399336 0.794610437242617 5.25872858861507 2.47869001042179 -2.2130389597346 -2.77115450299921 -0.92580663946209 -2.12358209498442 -0.864235817298387 2.26031574145054 -3.38429940704009 2.81292668173762 -2.80924315047952 -1.15931761624331 -0.381255338266444 -0.696581455256773 4.08359881727522 0.711279751613718 -1.97397906279608 1.71880826239543 -2.50973020456323 -3.04365993415312 -0.649655609705208 -2.76032248193342 -2.43002949486167 0.67812686692575 0.642133153367048 2.05393263540948 2.99017059866047 1.53791600445262 -0.689737387487738 3.2432748072057 -0.469356245467646 3.92805340352299 0.405589258009754 -0.824917865099851 -2.56606726049183 -2.00588619077232 -1.80043279608072 -4.03596190128757 3.36819643912387 2.08914075294134 -0.914501121549696 -0.979313885830671
10 | "9" -2.88503299717775 5.55401245714279 0.90227891536358 3.55207049493334 -3.07267886127409 -2.15351798485481 -0.263772316023579 0.715506431079379 5.36524923518353 2.68351499908295 -2.26988241425298 -2.7579165757886 -0.833355990329643 -1.97907708562914 -1.20043942103598 2.23808125439809 -3.2823528048757 3.20003973338261 -2.7311846463044 -0.906043163473806 -0.168109038820046 -0.952382981352919 3.90386302085776 0.852501033322235 -2.02679995324184 1.90729055665981 -2.20801731071435 -2.77061707670568 -0.501201515804305 -2.52882488192182 -2.30153123458359 0.800619961936553 0.465400921518128 1.79478955952191 2.56258538565852 1.81742525096541 -0.634077436678074 3.34220669731705 -0.536043569582497 3.31049394879018 0.169989562077099 -1.01571221155307 -2.71582066613543 -1.83216337370951 -1.95452782149707 -3.8833389385233 3.25298217989329 1.9797880727078 -1.0553316267609 -1.11007899554668
11 | "10" -3.12624555917061 5.29578404519326 1.1608309397547 3.49813082385028 -3.05944705069455 -2.01448851352612 -0.471158531405204 0.477313304719211 5.31244767027944 2.58875303609224 -1.99108480393716 -2.76828236922445 -0.856353812345781 -2.00892037409214 -1.00620967266643 1.94929680350831 -3.39387089345774 3.1380552325502 -2.87003181565642 -0.903715818743976 -0.129966325282889 -0.955983571250505 3.52053553590823 0.671077106691063 -1.95806291305308 1.92421422190917 -2.13541312282767 -2.66346869585217 -0.862125748827429 -2.4085387814498 -2.30221086742493 0.761959811443182 0.549408899934338 1.84295245615312 2.67974928412672 2.10881133942777 -0.467525444901047 3.17801118078815 -0.314986214438436 3.0014901644336 0.160181213230833 -1.04146323658883 -2.65905763064459 -2.00764249864159 -1.75009385695244 -3.7712426819231 3.15926043481665 1.72102110773145 -0.914706252442915 -1.1782731922836
12 | "11" -2.8037855058339 5.14933572687401 1.04717165265884 3.41467195176591 -2.9990729733678 -1.89678915015216 -0.744158607867287 0.451481653363297 5.54133329613637 2.5540526626979 -1.95602194737785 -2.86387916051623 -0.747095930595297 -1.69370648390437 -1.05580987842928 1.77732609636731 -3.27201957641815 2.79469793043725 -2.75578113699482 -0.662733838556205 -0.358940694046606 -1.11219348688337 3.21372702391413 0.583155114185506 -1.88407238292935 1.75647846744146 -2.27670551413639 -2.65950938129706 -1.07891411103875 -2.39931603677661 -2.38176106978569 0.460977562655999 0.130547356645363 1.79743310621025 2.33048085580204 2.08739975859503 -0.307923525155761 2.95107442791418 -0.435529234644761 3.11489944031958 -0.1657833748962 -1.20045217895967 -2.49005005364775 -1.8653858526997 -1.48814453344282 -3.34903689565987 2.98075691370478 1.75513591712446 -0.510950664855706 -0.924633935436165
13 | "12" -4.56500282046552 -2.50156037266725 -9.1239464657499 -0.411976355355413 -4.53415347521539 6.26578759153863 23.7862414390073 5.75591608959253 -4.5538731650678 9.13465492355513 -12.2566971192385 -0.328124195405556 2.42066627759478 -16.442997530988 6.6139675797512 2.70875215612388 -4.45678599552866 -6.47249467962163 -11.7790246463468 -5.15431192532614 -10.425660828522 5.42338984516667 13.1174407077473 -4.33022573484992 10.6717937393781 19.9863151842939 12.3587537987699 -17.7346039744637 -21.1656476725884 1.78392714281578 18.1213358448086 -17.6751057294376 -13.8812536179932 4.19516362059936 19.5683355749467 18.7100426997121 1.77390574176479 -0.702539671607918 5.82246321796912 -1.64612929797943 3.30977447978466 -10.3602227493548 0.375779693095 31.2568078731423 -14.379159694374 5.26390027616037 12.9022503489886 -12.8395077990269 -7.99587164630095 8.31927803004067
14 | "13" -1.27748657691494 -2.16048355206604 -8.10065820145534 3.65540749951009 1.94009896709301 1.05470099612592 5.21348857168673 -0.692874916079521 -1.06184152526245 4.03793162848289 -4.98927968798942 -1.25048447895361 2.06153809321973 -5.56846297944219 2.04006172107523 0.299712253528269 -5.16641978480819 -4.41347719813818 -3.32379549227365 -1.42153873446019 -1.10901777657457 -2.35582873097846 4.40681231761638 -4.99178246497899 -0.102916989950528 5.78872234432312 2.00463718903067 -4.24750650948302 -7.28062123497169 -1.16050456936447 6.94336622996254 -6.54249399508194 -2.25343312347686 0.186216627351754 6.54310437956914 3.09457678413499 -1.19231192787264 4.91969353487272 -0.326890076682449 1.33009582837932 3.03141102326107 -2.51526136828861 1.50637146160538 10.4164509661103 -1.61202725048103 0.0841130877989625 4.40691341965148 -2.51627951363948 -0.334607417595847 3.54277373066602
15 | "14" -1.38980487464302 -2.05605487037133 -7.83168863278535 3.38901177764911 2.42000737154548 1.01113785561116 5.21049248350889 -0.603691934071496 -0.972102491211581 4.21396230146225 -4.63369701317935 -1.40707020800934 1.90015152702511 -5.02707988579675 1.83911696608642 0.100420533814667 -5.22206822238571 -4.07605045702368 -3.10010859011506 -1.3306391984967 -1.12564921587413 -2.35888292933491 4.2851176816648 -4.89451784568213 -0.320218976622552 6.20723288560077 2.11840919867503 -4.11191311134443 -7.2398808880971 -0.877282080277322 6.43218681706082 -6.55599054324182 -2.11969290317785 -0.07596527999286 6.16041187211122 3.04251198261731 -1.06418321007018 4.49512498584488 0.127939022857176 1.15408448136765 3.12631459640297 -2.1909259298332 1.89307942080815 10.7152505058125 -1.60045177901867 -0.488304276206163 3.56958307582576 -2.44632812134068 -0.184162262482335 3.27367535489631
16 | "15" -1.42811773957422 -1.86555600313361 -7.59460407377957 3.80631291892529 2.51577345766762 0.831943850711179 5.15900285500335 -0.162077200868055 -0.353557723452163 4.31398022029575 -4.80321785326543 -1.13144117755545 1.58255309884654 -5.47788945919531 2.2901504583708 -0.0468673157872053 -4.89802150745631 -4.68627875030325 -2.54330293661339 -1.25666094805702 -1.70988537488397 -2.21766267764691 4.0499482249993 -4.8305159472549 -0.114070465281071 6.03283506847771 1.7612504388953 -4.23368487470028 -7.42616106675881 -0.751645994880171 6.36290819024856 -6.34832789813645 -1.31449425648605 -0.143997388058828 5.86320156831682 3.07533531682761 -0.997452715737789 3.89913944150644 -0.522057533444702 0.950503513748549 2.78912735529358 -2.00340829633772 1.52194512935792 9.95503967065683 -1.22363908757146 0.05117431509057 3.69534158283981 -2.28617394021492 -0.268374038941386 2.87092710687567
17 | "16" -1.06587490913676 -1.75141011197286 -6.98452362702912 3.64577945691355 3.07082053141414 0.650092101627203 5.13761306810303 -0.0394609713846614 -0.242109432930716 3.90027048493943 -4.45767535785733 -0.811145123476882 1.32341340388603 -5.04754588947868 2.16802821406035 0.268088225351855 -4.16378068801057 -4.27834717051036 -2.11312801327928 -0.77680965860063 -1.47411142605847 -1.88990830455403 3.82759725762676 -4.69942491711423 -0.275355401213381 5.72985229386707 1.63935085478783 -3.35602966988621 -6.9735121031824 -0.208713611461344 6.51350401615933 -5.99416522934026 -1.35985783449956 -0.054943024517851 5.46083831461561 2.8580558389104 -1.35536601689017 4.25767783893166 -0.117837139877337 0.933244422840175 2.71953988843241 -1.80356348215353 1.8524699891466 9.58698145396707 -1.23450379119085 0.246474071311136 3.17157904056146 -2.45447937106442 -0.0995117824624573 2.68561784563634
18 | "17" -1.22673686644754 -2.16999377846404 -6.18201624320526 2.83810340022607 2.99344393792732 0.968633830093865 4.88702298696879 0.437785919172593 -0.121335589377627 3.65496207802541 -4.63565076714187 -1.25902341427939 0.891031255093537 -4.76298052420752 2.32964487698632 0.534333622043948 -4.17811286397574 -3.96697942983904 -1.90684515552988 -1.00168904561263 -0.853354659512818 -2.35713057093288 3.94603663370684 -4.50812161733374 -0.835795036890181 5.72442990760914 2.06496035172091 -2.91846176529612 -6.79260145049685 -0.651324533321607 5.8173786395879 -5.55361795262645 -1.19806675070786 0.0347728016990473 4.91451528624333 2.50409693656804 -1.28440263730609 4.14939729565662 0.0635039073458724 1.55736116790541 2.9427659324107 -1.5477673996958 1.70161372965177 9.81570918777643 -1.02116636555602 0.400082339134099 2.99460342258219 -3.22193224071833 0.206039097496807 3.03475950301275
19 | "18" -1.19986397187544 -1.89652090927935 -6.62361471624466 3.12077510023686 3.32071500720409 1.34486304788585 4.51191166475996 0.259565861853603 0.0192244143383152 4.00642828895488 -4.86008721899753 -1.46895971278109 1.58053557939373 -4.1297000305658 2.57045234330308 0.156063196826457 -3.56029213251976 -4.0012757760037 -1.31216233739192 -0.754358839456864 -0.774174198787813 -2.61195267248822 4.23114693063027 -4.42438404682405 -0.861918299362311 5.20949175126684 2.09718902340082 -2.97526671704115 -6.23673779442063 -0.878542851937642 5.72514710275419 -5.35213152695941 -1.33612994380217 0.505845990803159 4.80959035347754 2.35310074522499 -0.955127312926293 3.93789858232566 0.171804386571905 1.26534029014865 3.09408785360798 -1.06591322268688 2.16770498848751 8.65003333115158 -0.967310568657448 0.542575446894657 3.43135971635769 -3.19806644256422 0.453834081613882 2.80100138460147
20 | "19" -1.10427450562383 -1.60170494535817 -7.14670565593266 2.95138843949603 3.15186656643546 1.22969667042707 3.90535141886771 0.114060012583617 -0.355467146041209 4.34268484023661 -4.78939140970999 -1.10241067340872 1.49548264067149 -4.35091831542172 2.89752458592473 0.163541363750271 -2.88798717702894 -4.40209171180596 -1.27990736133764 -0.536475161124278 -1.06822819872825 -2.25273898382662 3.68157020276083 -4.11575611239377 -0.887646323935796 5.01392033069049 2.11471841738924 -3.16422076165993 -6.05697604525869 -1.31591183146637 5.51742659768627 -4.99850266035827 -1.26983139400181 0.800455446319762 4.9020791490291 2.55229056013083 -0.598636964860425 3.77081738634503 0.239355124621535 0.822245025484323 2.51974351168806 -0.618871140648366 2.45382273870506 8.62490179040105 -0.713452566020891 -0.0778818024394132 3.05866468402962 -3.07770821005019 0.710283322929891 2.66147266559266
21 | "20" -0.797358522537883 -1.53518347825377 -7.48703041935417 3.44684830900019 2.90502361670605 0.838248119892189 4.08157111779497 0.125212301458273 -0.44634046279531 4.3910574632394 -5.09366021858691 -1.09761239081259 2.1543547138253 -4.31609864015837 2.76666642976805 0.299239414490608 -2.53067976234604 -4.44114920545072 -1.19907582885981 -0.651943713167906 -0.907246302479042 -1.74563671451765 3.70239684094026 -3.54957017747206 -1.27233160060047 4.31721134052887 2.15772028700271 -3.76684774572864 -5.55944872014313 -1.28484958142207 5.29812267643217 -4.71278615353093 -0.976671977923793 1.00780439995423 4.72164581995427 1.65109122049261 -1.11217999626386 3.32931766038652 0.57336716273155 0.9726708728265 2.10065619280954 -0.26407739113379 2.32751651232555 8.60730449188167 -0.541745377203705 -0.211978122298308 2.596138232737 -2.9695117323776 0.808102940415545 2.79966646862381
22 | "21" -0.930453009965325 -1.86334686954257 -7.38288622905628 3.50278792799359 2.70441956955568 0.796207005240092 3.29178004254878 0.205011198939747 -0.389936254656899 4.60184515643953 -4.91278275344958 -2.10755097366946 2.10800735663072 -4.20557740563872 2.47614440840662 0.81140185501183 -2.53274535026452 -4.16203623716147 -1.28640714270058 -1.39604716585506 -1.17536979873864 -2.01396952187538 3.28460297922394 -3.15717598586022 -1.28294774953625 3.78635235781888 2.37891763209084 -3.75009104838581 -5.36918524850495 -1.33681670149282 5.03319287998962 -4.15295422250761 -0.631564754891811 1.6290474076849 4.84924860622017 1.6281454297171 -1.00444020091203 3.11452192944579 0.333851168431608 1.09590536873477 2.2586835859151 -0.192897309652703 2.07126247713768 8.06338821937771 -0.701819016035124 -0.346878986253049 2.76436690033543 -2.89840096640999 0.762116261836607 3.0544622146094
23 | "22" -0.672666455885399 -1.21769356552247 -7.09158563918669 3.21377772271612 2.67609857647289 0.417182576369179 3.20104583164857 0.0749002019123026 -0.401116582234401 4.366238118477 -4.32099060621196 -1.86834643515683 1.67323488458456 -4.53733359339859 2.85805837708321 0.853100201816923 -2.23258625823755 -4.82036783675824 -1.10828165266216 -1.58229361967944 -1.00978886609255 -1.92167466002624 3.28637328255864 -3.04648585178581 -0.966219951748905 4.1614675398757 2.76789306660644 -3.63110818653414 -5.0202606258143 -1.70671609380448 4.80995459827743 -4.08974752972763 -0.60511605568677 0.874236139424268 4.98318475063835 1.63529517622926 -0.711294228820351 2.80736782084123 0.0541819910483532 1.12634843028599 2.39345947155226 -0.0746743454958631 1.85376173031523 8.13779843621569 -0.539604030191489 -0.845424730221749 2.60643226685974 -2.47886146410129 0.784412753290507 3.18358345353126
24 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_density.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_density.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_log.txt:
--------------------------------------------------------------------------------
1 | =============================================================
2 | Probit Bayesian Multiple Instance Classification
3 | =============================================================
4 | Start warming up 1000 MCMC samples!
5 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
6 | Finish warming up!
7 | -------------------------------------------------------------
8 | Start extracting 1000 MCMC samples!
9 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
10 | Finish MCMC sampling!
11 | =============================================================
12 | Elapsed time for chain1=1.633 mins: MCMC sampling is done!
13 | =============================================================
14 | Start warming up 1000 MCMC samples!
15 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
16 | Finish warming up!
17 | -------------------------------------------------------------
18 | Start extracting 1000 MCMC samples!
19 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
20 | Finish MCMC sampling!
21 | =============================================================
22 | Elapsed time for chain2=1.182 mins: MCMC sampling is done!
23 | Time difference of 2.81808 mins
24 | used (Mb) gc trigger (Mb) max used (Mb)
25 | Ncells 741552 39.7 1231381 65.8 1231381 65.8
26 | Vcells 1627404 12.5 8388608 64.0 8388594 64.0
27 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_psrf.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_psrf.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_trace.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_2000_Nwarm_1000_Nthin_100_trace.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_FDRs.txt:
--------------------------------------------------------------------------------
1 | "x"
2 | "1" 0.344821166647862
3 | "2" 0.29257289450632
4 | "3" 0.234289365327275
5 | "4" 0.17768742885022
6 | "5" 0.119998103546368
7 | "6" 0.0698962701390421
8 | "7" 0.0341251885369532
9 | "8" 0.0130677068821399
10 | "9" 0.00270763614237907
11 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_PSRF.txt:
--------------------------------------------------------------------------------
1 | "PSRF"
2 | "1" 17.6000317367486
3 | "2" 1.51405504283501
4 | "3" 5.39149877439328
5 | "4" 5.68034413238039
6 | "5" 10.8887294323737
7 | "6" 5.72136696744235
8 | "7" 35.5340071408617
9 | "8" 2.78257268638767
10 | "9" 2.32798758975217
11 | "10" 0.975469276397778
12 | "11" 5.41032107917209
13 | "12" 0.958157733389963
14 | "13" 2.53931802894608
15 | "14" 3.15386082809018
16 | "15" 1.41637638177275
17 | "16" 23.3942688843431
18 | "17" 3.33792647913795
19 | "18" 3.71839854370041
20 | "19" 2.54274120424618
21 | "20" 1.88832530603594
22 | "21" 1.29954260987064
23 | "22" 1.71803247163669
24 | "23" 6.40109640640594
25 | "24" 1.50628196079348
26 | "25" 0.996227652385526
27 | "26" 4.38712034937516
28 | "27" 7.27014602367265
29 | "28" 5.79168104468637
30 | "29" 1.11212276708001
31 | "30" 6.13482423213879
32 | "31" 2.67659612173103
33 | "32" 1.54415205084731
34 | "33" 1.89704856636946
35 | "34" 5.31276528973598
36 | "35" 14.1456355840518
37 | "36" 6.29523902445862
38 | "37" 1.16463064638042
39 | "38" 1.76048233746681
40 | "39" 0.958632001364255
41 | "40" 5.54897010773764
42 | "41" 1.00160786653638
43 | "42" 1.03678878335401
44 | "43" 3.26018110472216
45 | "44" 5.87521383105939
46 | "45" 1.520616018641
47 | "46" 1.02855446088943
48 | "47" 2.33742466497693
49 | "48" 1.71693412900825
50 | "49" 1.14815939883832
51 | "50" 0.95710499390843
52 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_autocorr.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_autocorr.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_b.txt:
--------------------------------------------------------------------------------
1 | "b.1" "b.2"
2 | "1" -3.76702718583628 24.4136462889459
3 | "2" -0.695286745411879 1.05628087630473
4 | "3" -0.722605461854356 1.05228907286614
5 | "4" -0.692920604941725 1.02030945192872
6 | "5" -0.741133355965263 1.09600811090189
7 | "6" -0.77083830166929 1.10794517534948
8 | "7" -0.6461872139489 0.912632867994323
9 | "8" -0.710979130541499 1.04321016315044
10 | "9" -0.751595284472269 1.09502853624188
11 | "10" -0.776845636351795 1.09066874361526
12 | "11" -0.747882003042335 0.99017567769547
13 | "12" -0.76931432893944 1.0493513292274
14 | "13" -0.641442339561094 0.921529559083855
15 | "14" -0.883406943499571 1.16729099695633
16 | "15" -0.750705674631864 1.0300769371611
17 | "16" -0.748334734787646 0.994375802449078
18 | "17" -0.581483913903621 0.762950020370491
19 | "18" -0.856185121282563 1.12217933444052
20 | "19" -0.820350023842165 1.05053711524342
21 | "20" -0.775261209226973 0.99915363419965
22 | "21" -0.70321498522675 0.911465386148479
23 | "22" -0.838536341117001 7.32657302361109
24 | "23" -0.158617964001463 -0.509140313974669
25 | "24" -0.176059606718319 -0.435778738489192
26 | "25" -0.148023036051004 -0.499790103947966
27 | "26" -0.00262012703018698 -0.647334923239429
28 | "27" -0.0314627615295309 -0.62763646248972
29 | "28" -0.00787121121426651 -0.664527101492619
30 | "29" -0.114528655427479 -0.549212942864793
31 | "30" -0.0395582466314342 -0.664801641791747
32 | "31" -0.132234396872126 -0.524634486977473
33 | "32" -0.0733012034813125 -0.585816993974903
34 | "33" -0.144775739497615 -0.510600064143628
35 | "34" -0.167189483677617 -0.454778103182239
36 | "35" -0.0103246126093404 -0.664129508240172
37 | "36" -0.0516168309519978 -0.59500264607002
38 | "37" -0.303922534425863 -0.284532813035894
39 | "38" -0.0966206387129646 -0.516923257431294
40 | "39" 0.0158456300590721 -0.680476412186817
41 | "40" 0.00646647103530414 -0.667515530792466
42 | "41" -0.0636329693306871 -0.535948729769849
43 | "42" -0.0136462254879265 -0.646538815252268
44 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_density.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_density.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_log.txt:
--------------------------------------------------------------------------------
1 | =============================================================
2 | Probit Bayesian Multiple Instance Classification
3 | =============================================================
4 | Start warming up 2000 MCMC samples!
5 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
6 | Finish warming up!
7 | -------------------------------------------------------------
8 | Start extracting 2000 MCMC samples!
9 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
10 | Finish MCMC sampling!
11 | =============================================================
12 | Elapsed time for chain1=2.839 mins: MCMC sampling is done!
13 | =============================================================
14 | Start warming up 2000 MCMC samples!
15 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
16 | Finish warming up!
17 | -------------------------------------------------------------
18 | Start extracting 2000 MCMC samples!
19 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
20 | Finish MCMC sampling!
21 | =============================================================
22 | Elapsed time for chain2=1.798 mins: MCMC sampling is done!
23 | Time difference of 4.640749 mins
24 | used (Mb) gc trigger (Mb) max used (Mb)
25 | Ncells 741552 39.7 1231381 65.8 1231381 65.8
26 | Vcells 1628444 12.5 8388608 64.0 8388364 64.0
27 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_psrf.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_psrf.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_trace.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_4000_Nwarm_2000_Nthin_100_trace.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_FDRs.txt:
--------------------------------------------------------------------------------
1 | "x"
2 | "1" 0.542489639533974
3 | "2" 0.441705538854912
4 | "3" 0.362779728616638
5 | "4" 0.291538752771918
6 | "5" 0.234984842493739
7 | "6" 0.184433317049341
8 | "7" 0.139255804311774
9 | "8" 0.0929446669633586
10 | "9" 0.046531007751938
11 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_PSRF.txt:
--------------------------------------------------------------------------------
1 | "PSRF"
2 | "1" 0.9968545754809
3 | "2" 1.00563013133011
4 | "3" 1.00289415224888
5 | "4" 1.00384702746389
6 | "5" 1.00431314105345
7 | "6" 1.00579026391116
8 | "7" 1.0002764733144
9 | "8" 1.00083749072886
10 | "9" 1.00303845741057
11 | "10" 1.00140356637583
12 | "11" 1.00666855523632
13 | "12" 0.996680587308059
14 | "13" 1.005045445521
15 | "14" 1.00024310929872
16 | "15" 0.99699222873373
17 | "16" 0.997197643627426
18 | "17" 1.00254305967244
19 | "18" 0.998980466807431
20 | "19" 0.996689684600532
21 | "20" 1.00814355436312
22 | "21" 0.999998443552348
23 | "22" 1.00746916081814
24 | "23" 1.00455105933382
25 | "24" 1.00135114228052
26 | "25" 0.997225533828258
27 | "26" 0.997352778089666
28 | "27" 1.00031247693743
29 | "28" 1.00490146107416
30 | "29" 1.00110768650328
31 | "30" 1.00478141241054
32 | "31" 0.999504015655174
33 | "32" 1.00511315628973
34 | "33" 1.00592418926701
35 | "34" 1.00744981421829
36 | "35" 0.996758585237601
37 | "36" 1.00619572909273
38 | "37" 0.99939090891944
39 | "38" 1.00728069988593
40 | "39" 1.00398423218811
41 | "40" 1.00215331095185
42 | "41" 1.00525708731914
43 | "42" 0.996678439512008
44 | "43" 1.0070834563467
45 | "44" 0.998006013635288
46 | "45" 1.00417806462821
47 | "46" 1.0027884465577
48 | "47" 1.0029084302301
49 | "48" 1.00822709579382
50 | "49" 0.996679980439917
51 | "50" 1.00240002014557
52 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_autocorr.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_autocorr.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_density.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_density.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_log.txt:
--------------------------------------------------------------------------------
1 | =============================================================
2 | Probit Bayesian Multiple Instance Classification
3 | =============================================================
4 | Start warming up 20000 MCMC samples!
5 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
6 | Finish warming up!
7 | -------------------------------------------------------------
8 | Start extracting 30000 MCMC samples!
9 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
10 | Finish MCMC sampling!
11 | =============================================================
12 | Elapsed time for chain1=14.344 mins: MCMC sampling is done!
13 | =============================================================
14 | Start warming up 20000 MCMC samples!
15 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
16 | Finish warming up!
17 | -------------------------------------------------------------
18 | Start extracting 30000 MCMC samples!
19 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
20 | Finish MCMC sampling!
21 | =============================================================
22 | Elapsed time for chain2=9.607 mins: MCMC sampling is done!
23 | Time difference of 23.95437 mins
24 | used (Mb) gc trigger (Mb) max used (Mb)
25 | Ncells 741552 39.7 1231381 65.8 1231381 65.8
26 | Vcells 1657565 12.7 11829370 90.3 14786654 112.9
27 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_psrf.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_psrf.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_trace.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_50000_Nwarm_20000_Nthin_100_trace.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_FDRs.txt:
--------------------------------------------------------------------------------
1 | "x"
2 | "1" 0.507283855813533
3 | "2" 0.459357209398613
4 | "3" 0.402253433208489
5 | "4" 0.333236434108527
6 | "5" 0.241584910067741
7 | "6" 0.14823509252913
8 | "7" 0.0847020018198362
9 | "8" 0.0402834599649328
10 | "9" 0.0123779113448535
11 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_PSRF.txt:
--------------------------------------------------------------------------------
1 | "PSRF"
2 | "1" 0.975736960742356
3 | "2" 1.13851954608357
4 | "3" 9.02072705114734
5 | "4" 1.61111517235511
6 | "5" 1.89077139741461
7 | "6" 1.04526154463803
8 | "7" 1.49388693744789
9 | "8" 1.31207265569047
10 | "9" 1.58109312785317
11 | "10" 1.02343024414655
12 | "11" 1.2254289509448
13 | "12" 1.0604386733404
14 | "13" 8.93467217762442
15 | "14" 1.00451791826979
16 | "15" 1.64952094956211
17 | "16" 1.21972390618548
18 | "17" 1.44136145790917
19 | "18" 1.38320317486649
20 | "19" 4.07082297498415
21 | "20" 1.75232515502226
22 | "21" 4.42277220489478
23 | "22" 4.9445869654798
24 | "23" 2.96903668182821
25 | "24" 33.1625114118354
26 | "25" 1.18249209934372
27 | "26" 1.29819413713016
28 | "27" 1.76197935904785
29 | "28" 3.12209326575287
30 | "29" 1.85912444001915
31 | "30" 9.29094703305953
32 | "31" 1.10450030461429
33 | "32" 1.19118673114583
34 | "33" 2.69237878217109
35 | "34" 1.61604899606158
36 | "35" 2.84340327146884
37 | "36" 1.51301984858517
38 | "37" 2.19864000776039
39 | "38" 1.13205595402704
40 | "39" 0.977681911677446
41 | "40" 0.999747745097238
42 | "41" 2.24302073089834
43 | "42" 3.45086477177117
44 | "43" 1.72920395689086
45 | "44" 1.07630889730907
46 | "45" 1.09811012597926
47 | "46" 2.53546772624532
48 | "47" 3.4012297165059
49 | "48" 0.976214683792083
50 | "49" 5.77926393556934
51 | "50" 0.975829610103702
52 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_autocorr.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_autocorr.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_b.txt:
--------------------------------------------------------------------------------
1 | "b.1" "b.2"
2 | "1" -3.76702718583628 24.4136462889459
3 | "2" -0.81136900768844 0.983738427338689
4 | "3" -0.720773617564973 0.918477240489822
5 | "4" -0.764187417384101 0.942436843359056
6 | "5" -0.593728268482323 0.657506974173759
7 | "6" -0.648550961236305 0.775473812431907
8 | "7" -0.395504975164804 0.374545822292596
9 | "8" -0.519557007432511 0.60991833760071
10 | "9" -0.55916172785562 0.666054447323704
11 | "10" -0.514017365883742 0.630348816381232
12 | "11" -0.388432413333686 0.389884392113565
13 | "12" -0.330908658124268 0.319419137195124
14 | "13" -0.511690545434545 0.529664468534214
15 | "14" -0.305377768903184 0.265340116609954
16 | "15" -0.199927524776157 0.123721238940282
17 | "16" -0.316083996037225 0.260213398096244
18 | "17" -0.179011528508024 0.106972685117325
19 | "18" -0.0888637937494952 -0.028427327618115
20 | "19" -0.036762750819738 -0.0885704078117614
21 | "20" 0.014896296247314 -0.167047082101595
22 | "21" -0.00955688294957289 -0.0704870425495504
23 | "22" -0.026853147528161 -0.0706684577072335
24 | "23" 0.157378425786862 -0.333429836265337
25 | "24" 0.16081801933947 -0.379796412202317
26 | "25" 0.39651689609912 -0.692782733190456
27 | "26" 0.266837490801183 -0.562704346717075
28 | "27" 0.308839961086366 -0.572790943627429
29 | "28" 0.449326956029306 -0.673748600974233
30 | "29" 0.275773647849808 -0.505046292388746
31 | "30" 0.421888277606779 -0.63898569265957
32 | "31" 0.25826322818007 -0.508019941965192
33 | "32" 0.440199153857371 -0.711247477678718
34 | "33" 0.501016207922434 -0.746695970431095
35 | "34" 0.445603952861266 -0.658526520796573
36 | "35" 0.607197728663704 -0.876382243341869
37 | "36" 0.676343320714311 -0.942015480453174
38 | "37" 0.42218587227005 -0.643297646881319
39 | "38" 0.555638780509445 -0.820816479833321
40 | "39" 0.804087352731466 -1.14724217831347
41 | "40" 0.798378173712596 -1.22062314149758
42 | "41" 0.831229863185353 -1.19179593379434
43 | "42" 7.23711460494876 -0.0127041613364398
44 | "43" -0.137594758883637 -0.591016375913584
45 | "44" -0.246484658715081 -0.450958241175914
46 | "45" -0.167863690750383 -0.528529393691712
47 | "46" -0.262263490268738 -0.406754842545468
48 | "47" -0.120910488157046 -0.597129983687403
49 | "48" -0.132701688197411 -0.520271558932692
50 | "49" -0.134552596492438 -0.526297819102457
51 | "50" -0.235040006218873 -0.443098329133109
52 | "51" -0.217108345283117 -0.44991698145233
53 | "52" -0.177573062572358 -0.54157662007978
54 | "53" -0.185948000588631 -0.55663973809654
55 | "54" -0.0117744420576572 -0.740209960624925
56 | "55" -0.0130890313095337 -0.713154884502669
57 | "56" -0.0964946515293647 -0.609138392660743
58 | "57" -0.0204823624294145 -0.700760010897548
59 | "58" -0.103409107785637 -0.612384094428471
60 | "59" -0.166887726938424 -0.489233858175988
61 | "60" -0.0682584173747814 -0.639803750624142
62 | "61" 0.0231369854459643 -0.743736942095076
63 | "62" -0.0712893346984002 -0.591825509416679
64 | "63" -0.0399429895644133 -0.635346937487537
65 | "64" 0.0325772320260792 -0.814019164763151
66 | "65" 0.0319528108934538 -0.734920827174505
67 | "66" -0.0263215227757799 -0.656776891354007
68 | "67" -0.0606006146618587 -0.616946555457208
69 | "68" -0.181575195285205 -0.422063313874908
70 | "69" -0.128629259209124 -0.494849301089339
71 | "70" 0.0598830446462778 -0.815438952174385
72 | "71" -0.107055915323847 -0.560657713186099
73 | "72" -0.190083614389615 -0.408480235230702
74 | "73" -0.0150001187753118 -0.614738888997149
75 | "74" 0.0225978685032235 -0.655388116257483
76 | "75" -0.00306510916743606 -0.630760505835802
77 | "76" 0.173652073399688 -0.857640332532674
78 | "77" 0.14589052328113 -0.808980323616661
79 | "78" 0.293941192231801 -0.980148794472272
80 | "79" 0.0449220157429771 -0.654383792440622
81 | "80" 0.13596332927422 -0.745748558175472
82 | "81" 0.111309500805502 -0.675252883546573
83 | "82" 0.333306807565189 -0.994974548513306
84 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_density.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_density.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_log.txt:
--------------------------------------------------------------------------------
1 | =============================================================
2 | Probit Bayesian Multiple Instance Classification
3 | =============================================================
4 | Start warming up 4000 MCMC samples!
5 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
6 | Finish warming up!
7 | -------------------------------------------------------------
8 | Start extracting 4000 MCMC samples!
9 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
10 | Finish MCMC sampling!
11 | =============================================================
12 | Elapsed time for chain1=4.779 mins: MCMC sampling is done!
13 | =============================================================
14 | Start warming up 4000 MCMC samples!
15 | Progress: 20 % ...40 % ...60 % ...80 % ...100 % ...
16 | Finish warming up!
17 | -------------------------------------------------------------
18 | Start extracting 4000 MCMC samples!
19 | Progress :20 % ...40 % ...60 % ...80 % ...100 % ...
20 | Finish MCMC sampling!
21 | =============================================================
22 | Elapsed time for chain2=2.475 mins: MCMC sampling is done!
23 | Time difference of 7.257439 mins
24 | used (Mb) gc trigger (Mb) max used (Mb)
25 | Ncells 741552 39.7 1231381 65.8 1231381 65.8
26 | Vcells 1630524 12.5 8388608 64.0 8388504 64.0
27 |
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_psrf.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_psrf.pdf
--------------------------------------------------------------------------------
/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_trace.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yunguan-wang/Spacia/11809bbe38e9107ab2b4444466958fdf7ab1e369/tutorials/demo_data/noise_level_0.5_5_pathways/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100/spacia_noise_level_0.5_5_pathways_Ntotal_8000_Nwarm_4000_Nthin_100_trace.pdf
--------------------------------------------------------------------------------
/tutorials/python_interface_tutorial.md:
--------------------------------------------------------------------------------
1 | ## Introduction
2 | This is a simple tutorial for running Spacia on the test dataset manually in linux.
3 |
4 | ### Set up
5 | We assume Spacia was already installed. In most cases the python environment is managed by conda or mamba, and R is available through HPC.
6 | Let's say our python env's name is spacia, and the R version we want to use is 4.1.1.
7 | Load the spacia env.
8 |
9 | ```
10 | conda activate spacia
11 | module load R/4.1.1
12 | ```
13 |
14 | ### Input data
15 | First, navigate to the `Spacia`'s test data directory.
16 | ```
17 | cd [path/to/Spacia/test/input]
18 | ```
19 | Two files are essential for running Spacia, one is for gene expression and the other is metadata for each cell.
20 | Let's take a look at the expression data.
21 | ```
22 | head -n 5 counts.txt | cut -d $'\t' -f 1-6
23 | ```
24 |
25 | | | gene1 | gene2 | gene3 | gene4 | gene5 |
26 | | --- | ---| --- | ---| --- | ---|
27 | | cell_0 | 1.058939863 | 2.142738423 | 1.357627858 | 0.942371598 | 1.523920809 |
28 | | cell_1 | 0.973380302 | 2.423213296 | 1.428899385 | 1.208159298 | 1.165738144 |
29 | | cell_2 | 0.75562576 | 2.164291889 | 1.067379324 | 1.456489891 | 1.466352688 |
30 | | cell_3 | 0.820909431 | 2.011477308 | 1.249298614 | 1.181445221 | 2.132801071 |
31 |
32 | As we can see, the gene expression data is a cell-by-gene matrix, where the first column is cell names, and the first row is the gene names.
33 | This test data is a matrix of 2,844 cells by 100 simulated genes.
34 |
35 | Then, let's take a look at the metadata.
36 | ```
37 | head -n 5 spacia_metadata.txt
38 | ```
39 |
40 | | |X|Y|cell_type
41 | | --- | ---| --- | ---|
42 | cell_0|0|0|A
43 | cell_1|0|1|B
44 | cell_2|0|2|B
45 | cell_3|0|3|A
46 |
47 | The cell metadata contains spatial coordinates of each cell, as well as its cell type assignment. These three columns and their column names are manditory.
48 |
49 | ### Test case
50 | In this example, we would like to run Spacia to evaluate how `gene2` and `gene3` in cell_type `B` affects the expression of `gene1` in cell_type `A`.
51 | This can be done in executing the following command.
52 | ```
53 | python ../../spacia.py counts.txt spacia_metadata.txt -rc A -sc B -rf gene1 -sf gene2,gene3 -d 5 -m 2000,1000,10,1 -nc 20 -o single_gene_simple_agg
54 | ```
55 | Here, `-rc` and `-sc` specified the receiver and sender cell types.
56 |
57 | `-rf gene1` tells Spacia the response gene is `gene1` and `-sf gene2,gene3` indicates the signal genes are gene2 and gene3.
58 |
59 | `-d 5` tells Spacia to search for cell type A's neighboring cells within a radius of 5.
60 |
61 | `-m` specify the MCMC simulation parameters. In the test example, we set these numbers to be very small to ensure the calculation can finish in minutes. We recommend users to use default parameters for real datasets.
62 |
63 | `-nc 20` lets Spacia to use the mean expression of top 20 correlated genes of `gene1` as the response expression.
64 |
65 | Spacia will evaluate the effect of `gene2` on `gene1` and `gene3` on `gene1` simultaneously, and calculate beta values for `gene2` and `gene3`. On the other hand, since there is only one response, only one b value will be calculated, which is for `gene1`, evaluating the dependancy of interactions with `gene1` on cell-cell proximity.
66 |
67 | The command should finish in a few minutes, and results and logging information will be saved in the `single_gene_simple_agg` folder. Let's take a look.
68 | ```
69 | cd single_gene_simple_agg
70 | ls
71 | ```
72 |
73 | ```
74 | B_and_FDR.csv
75 | gene1_correlated_genes
76 | Interactions.csv
77 | Pathway_betas.csv
78 | model_input
79 | spacia_log.txt
80 | spacia_r.log
81 | ```
82 |
83 | The output folders contains the summarized results(B_and_FDR.csv, Interactions.csv, Pathway_betas.csv), intermediate results for each response gene(gene1_correlated_genes), and logging information(spacia_log.txt, spacia_r.log).
84 |
85 | `B_and_FDR.csv` contains the **b** values of each response gene/pathway (first column) and the associated significance information.
86 |
87 | `Pathway_betas.csv` contains the **beta** values representing the interaction between each response gene/pathway (first column) and signal gene/pathway (second columns).
88 |
89 | `Interactions.csv` contains the primary instance scores of all receivers in each receiver-sender cell pair (second and third column) for each response-signal interaction (first column).
--------------------------------------------------------------------------------
/tutorials/r_interface_tutorial.md:
--------------------------------------------------------------------------------
1 | ## Introduction
2 | This is a tutorial for manually running the Spacia R interface using the test dataset in linux.
3 | The R interface runs Spacia in a quality-optimized mode that does not support some of the options in the python interface.
4 |
5 | ### Set up
6 | The R interface does not require python, but it does require the same core R packages as well as some additional packages as detailed in the README.
7 | If only runnning the R interface, then install/load the correct version of R (and associated libraries/compilers if needed) and install the packages with:
8 |
9 | ```
10 | #example on a generic HPC environment
11 | module load R/4.1.1 gcc/12.2.0
12 |
13 | #start R session
14 | R
15 |
16 | #install core packages
17 | install.packages(c('coda', 'ggmcmc', 'Rcpp', 'RcppArmadillo', 'rjson'))
18 |
19 | #install R interface specific packages
20 | install.packages(c('optparse', 'filelock', 'ggplot2', 'patchwork', 'scales', 'gridExtra', 'dplyr'))
21 |
22 | #exit after all packages are installed
23 | Ctrl+D
24 | ```
25 |
26 | ### Input data
27 | The R interface can use the same input data as the python interface. Exit R and navigate to `Spacia`'s test data directory.
28 | ```
29 | cd [path/to/Spacia/test/input]
30 | ```
31 | Two files are essential for running Spacia, one is for gene expression and the other is the location metadata for each cell.
32 | Let's take a look at the expression data.
33 | ```
34 | head -n 5 counts.txt | cut -d $'\t' -f 1-6
35 | ```
36 |
37 | | | gene1 | gene2 | gene3 | gene4 | gene5 |
38 | | --- | ---| --- | ---| --- | ---|
39 | | cell_0 | 1.058939863 | 2.142738423 | 1.357627858 | 0.942371598 | 1.523920809 |
40 | | cell_1 | 0.973380302 | 2.423213296 | 1.428899385 | 1.208159298 | 1.165738144 |
41 | | cell_2 | 0.75562576 | 2.164291889 | 1.067379324 | 1.456489891 | 1.466352688 |
42 | | cell_3 | 0.820909431 | 2.011477308 | 1.249298614 | 1.181445221 | 2.132801071 |
43 |
44 | As we can see, the gene expression data is a cell-by-gene matrix, where the first column is cell names, and the first row is the gene names.
45 | This test data is a matrix of 2,844 cells by 100 simulated genes.
46 |
47 | Then, let's take a look at the metadata.
48 | ```
49 | head -n 5 spacia_metadata.txt
50 | ```
51 |
52 | | |X|Y|cell_type
53 | | --- | ---| --- | ---|
54 | cell_0|0|0|A
55 | cell_1|0|1|B
56 | cell_2|0|2|B
57 | cell_3|0|3|A
58 |
59 | The cell metadata contains spatial coordinates of each cell, as well as its cell type assignment. These three columns and their column names are manditory.
60 | Cell names must be consistent between the two input files. Also make sure that the coordinates of the cells are consistent and in the correct units;
61 | we highly recommend using microns as the unit of measure for distances.
62 |
63 | ### Test case
64 | In this example, we would like to run Spacia to evaluate how genes in cell_type `A` affects the expression of `gene2` in cell_type `B`.
65 |
66 | First, we need to find the necessay cutoff values. Unlike in the python interface, these values need to be speficied manually in the current version.
67 | Simply run Spacia without specifying any of the required cutoffs and plots will be generated to aid in determining the values.
68 | ```
69 | Rscript spacia.R \
70 | -x counts.txt \
71 | -m spacia_metadata.txt \
72 | -a spacia \
73 | -r B -s A -g gene2 \
74 | -d 2 \
75 | -o r_test/
76 | ```
77 | Here, `-r` and `-s` specifies the receiver and sender cell types.
78 |
79 | For sending genes, the R interface always aggregates all genes using PCA,
80 | which is the same behavior as passing `pca` to `--sender_features` in the python interface.
81 |
82 | `-g` specifies the receiving gene. There is no option to aggregate the receiving genes.
83 | If mulitple receiving genes are supplied by passing a file,
84 | then each gene will be processed in sequence in seperate Spacia runs.
85 |
86 | `-d 2` tells Spacia to consider "A" cells within 2 distance radius of "B" cells as potential interacting cells.
87 | This small value is intended to match the synthetic test data, and so should not be used for real data.
88 |
89 | `-o` specifies the output prefix. Inputs ending with "/" are intereted as directories,
90 | therefore `r_test` will be created to contain the outputs.
91 |
92 | Spacia will generate a cache file `A-B_cache.RData` and a plots pdf `gene2_cutoffPlot.pdf` under `r_test`.
93 | Open `gene2_cutoffPlot.pdf` and determine suitable cutoffs according to the instructions in the README.
94 | For this case, we can use 0.252 as the receiving gene correlation cutoff and 0.091 as the receiving gene quantile cutoff.
95 |
96 | We can then run Spacia using the cutoffs:
97 | ```
98 | Rscript spacia.R \
99 | -x counts.txt \
100 | -m spacia_metadata.txt \
101 | -a spacia \
102 | -r B -s A -g gene2 \
103 | -q 0.091 -u 0.252 \
104 | -d 2 -l 5000 -w 2500 \
105 | -o r_test/
106 | ```
107 |
108 | `-q` and `-u` are the receiving gene correlation and quantile cutoff values.
109 |
110 | `-l` and `-w` specify the MCMC simulation parameters.
111 | In the test example, we set these numbers to be very small to ensure the calculation can finish in minutes.
112 | We recommend users to use default parameters for real datasets.
113 |
114 | Alternatively, we can organize the cutoffs into a table (csv or tsv):
115 | ```
116 | head gene_cutoffs_A-B.txt
117 | ```
118 | |gene_name|cor_cutoff|quantile_cutoff
119 | | --- | ---| --- |
120 | gene2|0.252|0.091
121 |
122 | The gene cutoffs file can then be used instead of manually inputing the cutoffs:
123 | ```
124 | Rscript spacia.R \
125 | -x counts.txt \
126 | -m spacia_metadata.txt \
127 | -a spacia \
128 | -r B -s A \
129 | -t gene_cutoffs_A-B.txt \
130 | -d 2 -l 5000 -w 2500 \
131 | -o r_test/
132 | ```
133 |
134 | In this case, we can omit `-g`, which causes Spacia to attempt to sequentially process all genes listed in `gene_cutoffs_A-B.txt`,
135 | which is only `gene2` in this example. This can be useful in real analyses with many receiving genes.
136 | If using the same storage system and output directory, multiple Spacia instances can be run simultaneously using the same command.
137 | Otherwise, split the table for `-t` accordingly. Users can also specify a list of receiving genes by passing a text file to `-g`.
138 |
139 | For this example Spacia will evaluate the effect all genes from `A` cells to `gene2` in `B` cells simultaneously,
140 | and calculate beta values for each gene using its PCA weights.
141 | On the other hand, since there is only one response, only one b value will be calculated, which is for `gene2`,
142 | evaluating the dependancy of interactions with `gene1` on cell-cell proximity.
143 |
144 | The command should finish in a few minutes, and results and logging information will be saved in the `r_test` folder. Let's take a look.
145 | ```
146 | cd r_test
147 | ls
148 | ```
149 |
150 | ```
151 | A-B_cache.RData
152 | A-B_gene2_pip.csv
153 | A-B_gene2_betas.csv
154 | A-B_gene2.RData
155 | gene2_cutoffPlot.pdf
156 | ```
157 |
158 | The output folders contains the summarized results (A-B_gene2_betas.csv, A-B_gene2_pip.csv),
159 | a combined results data file (A-B_gene2.RData), and the previously generated plots (gene2_cutoffPlot.pdf).
160 |
161 | `A-B_gene2_betas.csv` contains both the the **beta** values representing the
162 | interaction between each signal gene/pathway (first columns) and response gene/pathway (second column),
163 | and the **b** values of each response gene/pathway (second column) along with the associated significance information.
164 | Since there is only one receiving gene per run, the **b** values are the same for all rows.
165 |
166 | `A-B_gene2_pip.csv` contains the primary instance scores of all receivers in each receiver-sender cell pair (first and second column)
167 | for each response-signal interaction (third column).
168 |
--------------------------------------------------------------------------------