Appearance
DEG Analysis
InSilicoLab Feature
This feature is exclusive to Portrai InSilicoLab.
Differential Expression Gene (DEG) analysis identifies genes that show statistically significant differences in expression between cell populations. This is essential for understanding biological differences between tissue regions, cell types, or experimental conditions.

Overview
What is DEG Analysis?
DEG analysis compares gene expression levels between two or more groups of cells to find:
- Upregulated genes - Higher expression in the target group
- Downregulated genes - Lower expression in the target group
- Statistically significant differences - Accounting for biological and technical variation
When to Use DEG Analysis
- Comparing tumor cells vs. normal cells
- Identifying marker genes for cell types
- Finding spatially variable genes
- Comparing treatment vs. control conditions
Opening DEG Analysis
- Click the DEG icon (DNA symbol) in the Activity Bar
- The DEG extension opens with:
- Sidebar - List of previous analysis results
- Workspace - New analysis form or result viewer

Setting Up Comparison Groups
DEG analysis requires defining at least two groups of cells to compare. Each group is defined using filter conditions.
Quick Setup
Quick Setup automatically creates groups based on a categorical annotation.

- In the Quick Setup section, select a categorical annotation from the Distribute by dropdown (e.g., cell_type)
- A preview panel appears showing all available labels with checkboxes
- Select which labels to include as groups (use Select All / Deselect All for convenience)
- Click Apply to create groups (minimum 2 labels required)
- If existing groups are present, a confirmation dialog asks whether to replace them
Manual Setup
For more control, manually configure each comparison group.

Adding Groups
- Click Add Group to create a new comparison group
- Groups are automatically named (Group A, Group B, etc.)
- Add at least 2 groups for comparison
Configuring Group Filters
Each group uses the same filter system as the Filter:
- Click on a group card to expand it
- Add filter conditions:
- Column conditions - Filter by annotation values
- Lasso conditions - Filter by spatial/embedding selection
- Variable Set conditions - Filter by gene set scores
- Combine conditions with AND/OR operators
- View the item count to verify your selection
Renaming Groups
- Click on the group name
- Enter a descriptive name (e.g., "Tumor Core", "Stromal Border")
- Press Enter to save
Using Filter Presets
Apply saved filter presets to quickly configure groups:
- Open the group's filter editor
- Click Load Preset
- Select a saved preset
- The preset's conditions are applied to the group
Handling Overlapping Items
When cells match multiple group criteria, you need to decide how to handle overlaps.
Overlap Statistics
The overlap handler shows:
- Number of overlapping items between each pair of groups
- Percentage of total items affected
- Adjusted item counts after applying the strategy
Overlap Strategies
| Strategy | Description | Best For |
|---|---|---|
| Allow overlaps | Keep items in all matching groups (warning only) | When overlap is intentional |
| Exclude from all | Remove overlapping items from all groups | Strictest separation |
| Keep in first group | Keep in the first matching group only | Priority-based assignment |
| Keep in largest group | Keep in the group with most items | Statistical power |
Choosing a Strategy
- Allow overlaps - Use when groups intentionally share items (e.g., comparing overlapping phenotypes)
- Exclude from all - Use when you need completely distinct populations
- Keep in first group - Use when groups have a natural priority order
- Keep in largest group - Use to maximize statistical power in each group
Validation
Before running analysis, the system validates your configuration.

Requirements
- Minimum 2 groups - At least two groups are required for comparison
- Sufficient items - Groups with very few items may produce unreliable results
Handling Empty Groups
When using Quick Setup, some categories may result in groups with no items (e.g., if certain cell types are absent from the current filter). Empty groups are shown as warnings rather than errors.

When you attempt to run analysis with empty groups:
- A confirmation dialog appears listing the empty groups
- You can choose to Exclude empty groups and continue - The analysis proceeds without the empty groups
- Or Cancel - Return to adjust your group configuration
TIP
Empty groups are automatically excluded from the analysis. You don't need to manually remove them if you choose to continue.
Validation Messages
| Type | Meaning |
|---|---|
| Error | Must be fixed before analysis can run |
| Warning | Analysis can run, but results may be affected (e.g., empty groups) |
Running Analysis
- Verify all groups are configured correctly
- Check the validation summary for errors
- Click Run DEG Analysis
- The analysis is submitted to the server
- Progress is shown in the Sidebar
Analysis Duration
Analysis time depends on:
- Number of cells in each group
- Number of groups being compared
- Server load
You can close the tab and return later - results are saved.
Understanding Results
Results List

Previous analysis results appear in the Sidebar:
- Click a result to view it
- Results show a progress indicator while processing
- Completed results can be reopened anytime
Result Tabs
- Open multiple results as tabs
- Switch between results to compare
- Close tabs when done
Heatmap View
The heatmap shows expression patterns across groups:
- Rows - Genes (filtered by significance)
- Columns - Comparison groups
- Colors - Expression level (log fold change)
- Clustering - Similar genes are grouped together
- Statistical Method - Displays the test used (e.g., "Wilcoxon rank-sum test")
Statistical Method
The heatmap configuration panel displays the statistical method used for differential expression testing:
| Method | Description |
|---|---|
| Wilcoxon rank-sum test | Non-parametric test comparing distributions between groups |
This information helps ensure reproducibility and proper interpretation of results.
Reading the Heatmap
- Red/warm colors - Higher expression (upregulated)
- Blue/cool colors - Lower expression (downregulated)
- Intensity - Magnitude of difference
Data Table
The data table provides detailed statistics for each gene:
| Column | Description |
|---|---|
| Gene Name | Gene symbol or identifier |
| Score | Statistical test score |
| Log Fold Change | log2(Group B / Group A) expression ratio |
| P-value | Raw statistical significance |
| Adjusted P-value (FDR) | Multiple testing corrected p-value |
Sorting Results
- Click column headers to sort
- Click again to reverse sort order
- Sort by adjusted p-value to find most significant genes
Filtering Results
FDR Threshold
Filter genes by statistical significance using False Discovery Rate (FDR):
| Level | Threshold | Description |
|---|---|---|
| No threshold | All | Show all genes |
| Exploratory | FDR < 0.1 | Lenient, for initial exploration |
| Standard | FDR < 0.05 | Commonly used significance level |
| High Confidence | FDR < 0.01 | Strict, high confidence results |
Choosing a Threshold
- Start with No threshold to see overall patterns
- Use Standard (0.05) for publishable results
- Use High Confidence (0.01) for validation candidates
Direction Filter
Filter genes by expression change direction:
| Filter | Criteria | Shows |
|---|---|---|
| All | - | All differentially expressed genes |
| Upregulated | logFC > 1 | Genes with higher expression in target |
| Downregulated | logFC < -1 | Genes with lower expression in target |
| Bidirectional | |logFC| > 1 | Strongly changed in either direction |
Interpreting Direction
- Upregulated (logFC > 1) - At least 2-fold higher in target group
- Downregulated (logFC < -1) - At least 2-fold lower in target group
- Bidirectional - Strongly changed regardless of direction
Exporting Results
Heatmap Image Export
Capture the heatmap as a PNG image:
- Open a completed DEG analysis result
- In the Heatmap Controls section, click Export Image
- The image downloads with current filter settings applied
The exported image includes:
- Heatmap with expression colors
- Gene names (rows)
- Group names (columns)
- Color scale legend
- Current filter settings (direction, FDR threshold, genes per group)
File naming format: DEG_Heatmap_{date}_{direction}_{fdr}_Top{n}.png
See Image Export for more details.
Data Table CSV Export
Export the full DEG results as a CSV file:
- Open a completed DEG analysis result
- In the Data Table section, click Export CSV
- The file downloads as
deg_results.csv
The exported CSV includes for each gene:
- Gene name
- For each comparison group:
- Log fold change (logFC)
- Adjusted P-value
- Score
Best Practices
Group Definition
- Use meaningful groups - Define groups based on biological questions
- Ensure sufficient size - Aim for at least 50-100 cells per group
- Check for overlaps - Review overlap statistics before analysis
- Name groups clearly - Use descriptive names for documentation
Result Interpretation
- Start broad, then filter - Begin with no thresholds, then apply filters
- Check multiple genes - Don't rely on single gene results
- Validate biologically - Confirm results make biological sense
- Document your analysis - Record group definitions and parameters
Common Pitfalls
| Issue | Solution |
|---|---|
| Too few significant genes | Relax FDR threshold or check group definitions |
| Too many significant genes | Use stricter FDR threshold or direction filter |
| Unexpected results | Verify group definitions match your hypothesis |
| Analysis fails | Check that groups have sufficient, non-overlapping items |
Troubleshooting
Analysis Won't Start
- Check validation summary for errors
- Ensure at least 2 groups are defined
- Verify each group has items selected
No Results After Analysis
- The analysis may still be processing (check progress)
- Try refreshing the results list
- Results expire after some time - rerun if needed
Unexpected Gene Rankings
- Verify group definitions are correct
- Check for overlapping items affecting statistics
- Consider the overlap handling strategy used
Related Topics
- Image Export - Export heatmap as PNG
- Filter - Filter conditions for group definition
- Lasso Selection - Spatial selection for groups
- Variable Sets - Gene sets for analysis