Skip to content

Commit

Permalink
Update the boxplot plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
yjcyxky committed Oct 10, 2024
1 parent 0965b8f commit c500cb1
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 31 deletions.
5 changes: 4 additions & 1 deletion cromwell-api-rs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.DS_Store
/target
/target
cromwell-8*.jar
cromwell-executions
cromwell-workflow-logs
40 changes: 40 additions & 0 deletions cromwell-api-rs/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## How to test the workflow

1. Start the cromwell server

```bash
java -jar cromwell-82.jar server
```

2. Install the dependencies

```bash
conda activate biomedgps
conda install -c conda-forge xxx

# Example for installing the R package
R -e "devtools::install_git('file:///Users/jy006/Documents/Code/BioMiner/omix-insight-r')"
```

3. Run the workflow

```bash
cargo run --example hello_world
```

## How to deploy the workflow

1. Rsync the workflow to the server

```bash
rsync -avP ./cromwell-api-rs/examples/boxplot/ [email protected]:/data/biomedgps/cromwell/workflows/boxplot-v0.1.0
```

2. Update the dependencies

```bash
# Login to the server

# Update the dependencies
/opt/miniconda3/envs/biomedgps/bin/R -e "devtools::install_git('file:///data/biomedgps/cromwell/workflows/boxplot-v0.1.0')"
```
2 changes: 1 addition & 1 deletion cromwell-api-rs/examples/boxplot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Generate boxplot for selected genes / proteins across groups.

- `exp_file`: Expression matrix file.
- `sample_info_file`: Sample information file.
- `which_entrez_ids`: Which entrez ids to select.
- `which_ids`: Which ids to select.
- `which_gene_symbols`: Which gene symbols to select.
- `which_groups`: Which groups to select.
- `output_file`: Output file.
Expand Down
6 changes: 3 additions & 3 deletions cromwell-api-rs/examples/boxplot/boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ library(OmixInsightR)
print("Running OmixInsightR for boxplot")

print("Querying data from expression matrix and sample information")
which_entrez_ids <- unlist(strsplit(args_json$which_entrez_ids, ","))
which_ids <- unlist(strsplit(args_json$which_ids, ","))
which_gene_symbols <- unlist(strsplit(args_json$which_gene_symbols, ","))
which_groups <- unlist(strsplit(args_json$which_groups, ","))

print(paste("Querying data from expression matrix and sample information:", args_json$exp_file, args_json$sample_info_file, which_entrez_ids, which_gene_symbols, which_groups))
print(paste("Querying data from expression matrix and sample information:", args_json$exp_file, args_json$sample_info_file, which_ids, which_gene_symbols, which_groups))
d <- query_data(
exp_file = args_json$exp_file,
sample_info_file = args_json$sample_info_file,
which_entrez_ids = which_entrez_ids,
which_ids = which_ids,
which_gene_symbols = which_gene_symbols,
which_groups = which_groups
)
Expand Down
2 changes: 1 addition & 1 deletion cromwell-api-rs/examples/boxplot/inputs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"boxplot.boxplot_task.exp_file": "/Users/jy006/Documents/Code/BioMiner/omix-insight-r/examples/gene_expression.tsv",
"boxplot.boxplot_task.sample_info_file": "/Users/jy006/Documents/Code/BioMiner/omix-insight-r/examples/sample_info.tsv",
"boxplot.boxplot_task.which_entrez_ids": [],
"boxplot.boxplot_task.which_ids": [],
"boxplot.boxplot_task.which_gene_symbols": ["BDNF", "TP53"],
"boxplot.boxplot_task.which_groups": ["Female_MECFS", "Female_Control"],
"boxplot.boxplot_task.method": "t.test",
Expand Down
6 changes: 3 additions & 3 deletions cromwell-api-rs/examples/boxplot/workflow.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ task boxplot_task {
input {
String exp_file
String sample_info_file
Array[String] which_entrez_ids
Array[String] which_ids
Array[String] which_gene_symbols
Array[String] which_groups
String method
Expand All @@ -23,7 +23,7 @@ task boxplot_task {
echo "Generating a args file, named args.json"
echo "exp_file: ~{exp_file}"
echo "sample_info_file: ~{sample_info_file}"
echo "which_entrez_ids: ~{sep=", " which_entrez_ids}"
echo "which_ids: ~{sep=", " which_ids}"
echo "which_gene_symbols: ~{sep=", " which_gene_symbols}"
echo "which_groups: ~{sep=", " which_groups}"
echo "method: ~{method}"
Expand All @@ -36,7 +36,7 @@ task boxplot_task {
{
"exp_file": "~{exp_file}",
"sample_info_file": "~{sample_info_file}",
"which_entrez_ids": "~{sep=',' which_entrez_ids}",
"which_ids": "~{sep=',' which_ids}",
"which_gene_symbols": "~{sep=',' which_gene_symbols}",
"which_groups": "~{sep=',' which_groups}",
"method": "~{method}",
Expand Down
77 changes: 73 additions & 4 deletions studio/src/StatEngine/components/ArgumentForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,80 @@ type DataItem = {
const datasets = [
{
datasetName: "GSE251790_Female_CSF",
datasetDescription: "[Protein] Deep phenotyping of Post-infectious Myalgic Encephalomyelitis/Chronic Fatigue Syndrome",
fieldValue: {
exp_file: "/data/biomedgps/cromwell/data/gene_expression.tsv",
sample_info_file: "/data/biomedgps/cromwell/data/sample_info.tsv",
exp_file: "/data/biomedgps/cromwell/data/GSE251790_Female_CSF/expression_data.tsv",
sample_info_file: "/data/biomedgps/cromwell/data/GSE251790_Female_CSF/sample_info.tsv",
},
fieldValueEnum: {
which_groups: ["Female_MECFS", "Female_Control"]
}
},
{
datasetName: "GSE245661_Female_Muscle",
datasetDescription: "[RNA-seq] Deep phenotyping of Post-infectious Myalgic Encephalomyelitis/Chronic Fatigue Syndrome",
fieldValue: {
exp_file: "/data/biomedgps/cromwell/data/GSE245661_Female_Muscle/expression_data.tsv",
sample_info_file: "/data/biomedgps/cromwell/data/GSE245661_Female_Muscle/sample_info.tsv",
},
fieldValueEnum: {
which_groups: ["HV", "MECFS"]
}
},
{
datasetName: "GSE254030_Female_Plasma",
datasetDescription: "[Protein] Deep phenotyping of Post-infectious Myalgic Encephalomyelitis/Chronic Fatigue Syndrome",
fieldValue: {
exp_file: "/data/biomedgps/cromwell/data/GSE254030_Female_Plasma/expression_data.tsv",
sample_info_file: "/data/biomedgps/cromwell/data/GSE254030_Female_Plasma/sample_info.tsv",
},
fieldValueEnum: {
which_groups: ["Female_MECFS", "Female_Control"]
}
},
{
datasetName: "GSE254030_Full_Plasma",
datasetDescription: "[Protein] Deep phenotyping of Post-infectious Myalgic Encephalomyelitis/Chronic Fatigue Syndrome",
fieldValue: {
exp_file: "/data/biomedgps/cromwell/data/GSE254030_Full_Plasma/expression_data.tsv",
sample_info_file: "/data/biomedgps/cromwell/data/GSE254030_Full_Plasma/sample_info.tsv",
},
fieldValueEnum: {
which_groups: ["MECFS", "Control"]
}
},
{
datasetName: "GSE254030_Male_Plasma",
datasetDescription: "[Protein] Deep phenotyping of Post-infectious Myalgic Encephalomyelitis/Chronic Fatigue Syndrome",
fieldValue: {
exp_file: "/data/biomedgps/cromwell/data/GSE254030_Male_Plasma/expression_data.tsv",
sample_info_file: "/data/biomedgps/cromwell/data/GSE254030_Male_Plasma/sample_info.tsv",
},
fieldValueEnum: {
which_groups: ["Male_MECFS", "Male_Control"]
}
},
{
datasetName: "MaureenHanson_Female_Plasma",
datasetDescription: "[Protein] In-Depth Analysis of the Plasma Proteome in ME/CFS Exposes Disrupted Ephrin-Eph and Immune System Signaling",
fieldValue: {
exp_file: "/data/biomedgps/cromwell/data/MaureenHanson_Female_Plasma/expression_data.tsv",
sample_info_file: "/data/biomedgps/cromwell/data/MaureenHanson_Female_Plasma/sample_info.tsv",
},
fieldValueEnum: {
which_groups: ["MECFS", "Control"]
}
},
{
datasetName: "Zenodo7781290_Bacterial_Viral",
datasetDescription: "A multi-platform approach to identify a blood-based host protein signature for distinguishing between bacterial and viral infections in febrile children (PERFORM): a multi-cohort machine learning study",
fieldValue: {
exp_file: "/data/biomedgps/cromwell/data/Zenodo7781290_Bacterial_Viral/expression_data.tsv",
sample_info_file: "/data/biomedgps/cromwell/data/Zenodo7781290_Bacterial_Viral/sample_info.tsv",
},
fieldValueEnum: {
which_groups: ["DefiniteBacterial", "DefiniteViral", "HealthyControl"]
}
}
]

Expand Down Expand Up @@ -133,8 +200,10 @@ const ArgumentForm: React.FC<ArgumentProps> = (props) => {
})
}}>
{datasets.map((dataset) => (
<Select.Option key={dataset.datasetName} value={dataset.datasetName}>
{dataset.datasetName}
<Select.Option key={dataset.datasetName} value={dataset.datasetName} style={{ width: '100%' }}>
<span>{dataset.datasetName}</span>
<br />
<span style={{ fontSize: '12px', color: 'gray', wordBreak: 'break-all', whiteSpace: 'normal' }}>{dataset.datasetDescription}</span>
</Select.Option>
))}
</Select>
Expand Down
19 changes: 2 additions & 17 deletions studio/src/StatEngine/components/ResultPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type { ChartResult } from '../WorkflowList/data';
import type { PlotlyChart } from 'biominer-components/dist/PlotlyViewer/data';
import { fetchFileByFileName } from '../../../services/swagger/KnowledgeGraph';
import type { Workflow, TaskHistory, FileMeta } from '../WorkflowList/data';
import { formatDuration } from './util';

// AG Grid theme
import 'ag-grid-enterprise';
Expand Down Expand Up @@ -207,23 +208,7 @@ const ResultPanel: React.FC<ResultPanelProps> = (props) => {
duration = finishedTime - startedTime;
}

const durationInSeconds = duration / 1000;

if (durationInSeconds <= 0) {
return '0s';
}

if (durationInSeconds < 60) {
return `${Math.round(durationInSeconds)}s`;
} else if (durationInSeconds < 3600) {
const minutes = Math.floor(durationInSeconds / 60);
const seconds = Math.round(durationInSeconds % 60);
return seconds > 0 ? `${minutes}min ${seconds}s` : `${minutes}min`;
} else {
const hours = Math.floor(durationInSeconds / 3600);
const minutes = Math.floor((durationInSeconds % 3600) / 60);
return minutes > 0 ? `${hours}h ${minutes}min` : `${hours}h`;
}
return formatDuration(duration);
};

useEffect(() => {
Expand Down
19 changes: 19 additions & 0 deletions studio/src/StatEngine/components/ResultPanel/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export const formatDuration = (duration: number) => {
const durationInSeconds = duration / 1000;

if (durationInSeconds <= 0) {
return '0s';
}

if (durationInSeconds < 60) {
return `${Math.round(durationInSeconds)}s`;
} else if (durationInSeconds < 3600) {
const minutes = Math.floor(durationInSeconds / 60);
const seconds = Math.round(durationInSeconds % 60);
return seconds > 0 ? `${minutes}min ${seconds}s` : `${minutes}min`;
} else {
const hours = Math.floor(durationInSeconds / 3600);
const minutes = Math.floor((durationInSeconds % 3600) / 60);
return minutes > 0 ? `${hours}h ${minutes}min` : `${hours}h`;
}
};
16 changes: 15 additions & 1 deletion studio/src/pages/OmicsData/TaskHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Table, Row, Tag, Space, message, Popover, Button, Input } from 'antd';
import type { ColumnsType } from 'antd/es/table';
import { TaskHistory, TaskHistoryTableData } from '../../StatEngine/components/WorkflowList/data';
import { fetchTasks, deleteTask } from '@/services/swagger/KnowledgeGraph';
import { formatDuration } from '../../StatEngine/components/ResultPanel/util';

type TaskHistoryTableProps = {
page?: number;
Expand Down Expand Up @@ -35,7 +36,7 @@ const TaskHistoryTable: React.FC<TaskHistoryTableProps> = forwardRef((props, ref
align: 'center',
dataIndex: 'task_name',
fixed: 'left',
width: 150,
width: 200,
},
{
title: 'Description',
Expand Down Expand Up @@ -90,6 +91,19 @@ const TaskHistoryTable: React.FC<TaskHistoryTableProps> = forwardRef((props, ref
},
width: 200,
},
{
title: 'Duration',
key: 'duration',
align: 'center',
width: 100,
render: (text, record) => {
const finishedTime = record.finished_time ? new Date(record.finished_time).getTime() : new Date().getTime();
const submittedTime = new Date(record.submitted_time).getTime();
const duration = finishedTime - submittedTime;

return formatDuration(duration);
},
},
{
title: 'Status',
dataIndex: 'status',
Expand Down

0 comments on commit c500cb1

Please sign in to comment.