Skip to content

Commit 68eafd1

Browse files
Dataset form cleanup (#187)
1 parent a103c0b commit 68eafd1

File tree

5 files changed

+123
-10
lines changed

5 files changed

+123
-10
lines changed

frontend/packages/@depmap/dataset-manager/src/components/ChunkedFileUploader.tsx

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
/* eslint-disable jsx-a11y/control-has-associated-label */
12
import * as React from "react";
2-
import { FormControl, ProgressBar } from "react-bootstrap";
3+
import { FormControl, HelpBlock, ProgressBar } from "react-bootstrap";
34
import { useState } from "react";
45
import { UploadFileResponse } from "@depmap/types";
56
import * as SparkMD5 from "spark-md5";
67

8+
import styles from "../styles/ChunkedFileUploader.scss";
9+
710
interface ChunkedFileUploaderProps {
811
uploadFile: (fileArgs: { file: File | Blob }) => Promise<UploadFileResponse>;
912
forwardFileIdsAndHash: (fileIds: Array<string>, hash: string | null) => void;
@@ -17,6 +20,96 @@ export default function ChunkedFileUploader({
1720
const [progress, setProgress] = useState(0);
1821
const [uploadSuccessful, setUploadSuccessful] = useState<boolean>(true);
1922

23+
const FormattingHelp = () => {
24+
return (
25+
<div>
26+
<div>
27+
Upload a dataset CSV file with <i>samples</i> and/or <i>features</i>.
28+
See below examples for more details.
29+
</div>
30+
31+
<details>
32+
<summary>Formatting Examples</summary>
33+
<div>
34+
<b>
35+
Matrix Dataset <i>(DEFAULT)</i>
36+
</b>
37+
<p>
38+
Samples (e.g. depmap models with &apos;depmap_id&apos; as their
39+
identifiers) are row headers and features (e.g. genes with
40+
&apos;entrez_id&apos; as their identifiers) are column headers
41+
</p>
42+
</div>
43+
<table className={styles.uploadExampleTable}>
44+
<thead>
45+
<tr>
46+
<th />
47+
<th>6663</th>
48+
<th>4893</th>
49+
</tr>
50+
</thead>
51+
<tbody>
52+
<tr>
53+
<td>ACH-00001</td>
54+
<td>0.05</td>
55+
<td>0.34</td>
56+
</tr>
57+
<tr>
58+
<td>ACH-00002</td>
59+
<td>0.4</td>
60+
<td>NA</td>
61+
</tr>
62+
</tbody>
63+
</table>
64+
65+
<div>Which in CSV format would be:</div>
66+
<pre>
67+
<div>,6663,4893</div>
68+
<div>ACH-00001,0.05,0.34</div>
69+
<div>ACH-00002,0.4,</div>
70+
</pre>
71+
72+
<div>
73+
<b>Tabular Dataset</b>
74+
<p>
75+
Samples or features as row headers and additional metadata are
76+
columns.
77+
</p>
78+
</div>
79+
<table className={styles.uploadExampleTable}>
80+
<thead>
81+
<tr>
82+
<th />
83+
<th>symbol</th>
84+
<th>status</th>
85+
<th>other metadata</th>
86+
</tr>
87+
</thead>
88+
<tbody>
89+
<tr>
90+
<td>6663</td>
91+
<td>SOX10</td>
92+
<td>Yes</td>
93+
<td>NA</td>
94+
</tr>
95+
<tr>
96+
<td>4839</td>
97+
<td>NRAS</td>
98+
<td>No</td>
99+
<td>123</td>
100+
</tr>
101+
</tbody>
102+
</table>
103+
<pre>
104+
<div>,symbol,status,other metadata</div>
105+
<div>6663,SOX10,Yes,</div>
106+
<div>4839,NRAS,No,123</div>
107+
</pre>
108+
</details>
109+
</div>
110+
);
111+
};
112+
20113
const chunkedUpload = async (file: File) => {
21114
const chunkSize = 5 * 1024 * 1024; // Arbitrarily set to 5MB. Adjust if necessary
22115
const totalChunks = Math.ceil(file.size / chunkSize);
@@ -84,6 +177,7 @@ export default function ChunkedFileUploader({
84177

85178
return (
86179
<div style={{ marginBottom: "10px" }}>
180+
<HelpBlock>{FormattingHelp()}</HelpBlock>
87181
<FormControl
88182
name="file_upload"
89183
type="file"

frontend/packages/@depmap/dataset-manager/src/components/DatasetForm.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,13 @@ export default function DatasetForm(props: DatasetFormProps) {
5252
Object.keys(matrixFormSchema.properties)
5353
.concat("allowed_values")
5454
.forEach((key) => {
55-
if (!isAdvancedMode && key === "value_type") {
56-
initForm[key] = "continuous";
55+
if (!isAdvancedMode) {
56+
if (key === "value_type") {
57+
initForm[key] = "continuous";
58+
}
59+
if (key === "data_type") {
60+
initForm[key] = "User upload";
61+
}
5762
} else if (
5863
typeof matrixFormSchema.properties[key] === "object" &&
5964
// @ts-ignore

frontend/packages/@depmap/dataset-manager/src/components/MatrixDatasetForm.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,15 @@ export function MatrixDatasetForm({
232232
},
233233
};
234234
if (!isAdvancedMode) {
235-
["feature_type", "value_type", "priority", "dataset_metadata"].forEach(
236-
(key) => {
237-
formUiSchema[key] = { "ui:widget": "hidden" };
238-
}
239-
);
235+
[
236+
"feature_type",
237+
"value_type",
238+
"priority",
239+
"dataset_metadata",
240+
"data_type",
241+
].forEach((key) => {
242+
formUiSchema[key] = { "ui:widget": "hidden" };
243+
});
240244
}
241245
return formUiSchema;
242246
}, [isAdvancedMode]);

frontend/packages/@depmap/dataset-manager/src/models/matrixDatasetFormSchema.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ export const matrixFormSchema: Required<Pick<RJSFSchema, "properties">> &
8585
group_id: {
8686
title: "Group Id",
8787
type: "string",
88-
description:
89-
"ID of the group the dataset belongs to. Required for non-transient datasets.",
88+
description: "The group the dataset belongs to",
9089
format: "uuid",
9190
},
9291
priority: {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.uploadExampleTable {
2+
border-collapse: collapse;
3+
border: 1px solid black;
4+
color: #333;
5+
6+
th,
7+
td {
8+
border: 1px solid black;
9+
padding: 4px;
10+
}
11+
}

0 commit comments

Comments
 (0)