Skip to content

Commit fd73afa

Browse files
committed
working implementation of resolvi routine
1 parent 649cd0c commit fd73afa

8 files changed

Lines changed: 1174 additions & 696 deletions

File tree

README.md

Lines changed: 166 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,183 @@ You can provide custom comparison specifications for both differential abundance
147147
--scviva_comparisons /path/to/scviva_comparisons.json
148148
```
149149

150-
**JSON format example:**
150+
## scVIVA Conditions Setup
151+
152+
The scVIVA workflow supports flexible condition specifications for niche-aware differential expression analysis. Conditions can be established through multiple approaches to enable sophisticated spatial comparisons.
153+
154+
### Condition Types
155+
156+
#### 1. **Cell Type Comparisons** (Simple)
157+
Compare different cell types without specific conditions:
158+
159+
```json
160+
[
161+
{
162+
"name": "tcells_vs_bcells_niche",
163+
"group1": "T cells",
164+
"group2": "B cells"
165+
}
166+
]
167+
```
168+
169+
#### 2. **Treatment/Disease Conditions**
170+
Compare the same cell type across different treatments or disease states:
151171

152172
```json
153173
[
154174
{
155-
"name": "tumor_vs_normal_tcells",
175+
"name": "treated_vs_control_tcells",
156176
"group1": "T cells",
157177
"group2": "T cells",
178+
"condition1": "treated",
179+
"condition2": "control",
180+
"condition_column": "treatment"
181+
}
182+
]
183+
```
184+
185+
#### 3. **Spatial Region Conditions**
186+
Compare cell types or conditions across different spatial regions:
187+
188+
```json
189+
[
190+
{
191+
"name": "core_vs_periphery_macrophages",
192+
"group1": "Macrophages",
193+
"group2": "Macrophages",
194+
"condition1": "tumor_core",
195+
"condition2": "tumor_periphery",
196+
"condition_column": "spatial_region"
197+
}
198+
]
199+
```
200+
201+
#### 4. **Sample-Based Conditions**
202+
Map specific samples to conditions when metadata isn't directly encoded:
203+
204+
```json
205+
[
206+
{
207+
"name": "tumor_vs_normal_epithelial",
208+
"group1": "Epithelial",
209+
"group2": "Epithelial",
158210
"condition1": "tumor",
159-
"condition2": "normal"
211+
"condition2": "normal",
212+
"condition_column": "tissue_type",
213+
"samples_condition1": ["tumor_sample1", "tumor_sample2", "tumor_sample3"],
214+
"samples_condition2": ["normal_sample1", "normal_sample2", "normal_sample3"]
160215
}
161216
]
162217
```
163218

164-
Both parameters also support CSV format with equivalent column names.
219+
#### 5. **Cross-Condition Cell Type Comparisons**
220+
Compare different cell types across different conditions:
221+
222+
```json
223+
[
224+
{
225+
"name": "tumor_tcells_vs_normal_bcells",
226+
"group1": "T cells",
227+
"group2": "B cells",
228+
"condition1": "tumor",
229+
"condition2": "normal",
230+
"condition_column": "tissue_type"
231+
}
232+
]
233+
```
234+
235+
### Condition Establishment Methods
236+
237+
The pipeline automatically detects and establishes conditions using the following priority order:
238+
239+
1. **Explicit condition column**: Uses the column specified in ```condition_column```
240+
2. **Sample mapping**: Creates conditions from ```samples_condition1``` and ```samples_condition2``` lists
241+
3. **Spatial regions**: Uses ```spatial_region``` column if available
242+
4. **Common metadata columns**: Automatically detects ```treatment```, ```tissue_type```, etc.
243+
5. **Sample ID fallback**: Uses ```sample_id``` as conditions if no other method works
244+
245+
### Required Data Preparation
246+
247+
Ensure your AnnData objects contain the necessary metadata:
248+
249+
#### Essential Columns
250+
- **Cell type predictions**: ```resolvi_predicted``` (automatically generated by ResolVI)
251+
- **Sample information**: ```sample_id``` (automatically added during preprocessing)
252+
253+
#### Optional Condition Columns
254+
- ```condition```: General condition labels
255+
- ```treatment```: Treatment/control labels
256+
- ```tissue_type```: Tissue or disease state labels
257+
- ```spatial_region```: Spatial region annotations
258+
- ```timepoint```: Temporal conditions
259+
- Custom condition columns as specified in your comparisons
260+
261+
### File Formats
262+
263+
#### JSON Format (Recommended)
264+
```json
265+
[
266+
{
267+
"name": "comparison_name",
268+
"group1": "Cell_Type_1",
269+
"group2": "Cell_Type_2",
270+
"condition1": "condition_A",
271+
"condition2": "condition_B",
272+
"condition_column": "metadata_column",
273+
"samples_condition1": ["sample1", "sample2"],
274+
"samples_condition2": ["sample3", "sample4"]
275+
}
276+
]
277+
```
278+
279+
#### CSV Format
280+
```csv
281+
name,group1,group2,condition1,condition2,condition_column
282+
tcells_vs_bcells,T cells,B cells,,,
283+
treated_vs_control_tcells,T cells,T cells,treated,control,treatment
284+
```
285+
286+
### Usage Examples
287+
288+
#### Basic cell type comparison:
289+
```bash
290+
nextflow run nf-core/resolvinf \
291+
--input samplesheet.csv \
292+
--scviva_comparisons simple_comparisons.json \
293+
--outdir results
294+
```
295+
296+
#### Complex condition-based analysis:
297+
```bash
298+
nextflow run nf-core/resolvinf \
299+
--input samplesheet.csv \
300+
--scviva_comparisons complex_comparisons.json \
301+
--annotation_label cell_type \
302+
--outdir results
303+
```
304+
305+
### Best Practices
306+
307+
1. **Minimum cell numbers**: Ensure each comparison group has ≥10 cells for reliable DE analysis
308+
2. **Balanced comparisons**: Try to have reasonably balanced group sizes when possible
309+
3. **Clear naming**: Use descriptive comparison names for easier interpretation
310+
4. **Condition validation**: Verify that your condition columns exist in the data
311+
5. **Sample mapping**: When using sample mapping, ensure sample IDs match exactly
312+
313+
### Troubleshooting
314+
315+
#### Common Issues:
316+
- **"Cannot establish conditions"**: Check that specified condition columns exist in your data
317+
- **"Insufficient cells"**: Reduce the number of comparisons or combine similar conditions
318+
- **"Sample not found"**: Verify sample IDs in ```samples_condition1/2``` match your data exactly
319+
320+
#### Debug Information:
321+
The pipeline logs detailed information about:
322+
- Available metadata columns
323+
- Condition establishment methods used
324+
- Cell counts for each comparison group
325+
- Success/failure status for each comparison
326+
165327

166328
## Key Parameters
167329

0 commit comments

Comments
 (0)