Skip to content

Commit

Permalink
Support Summarized Experiment derivatives (RDS file) (#145)
Browse files Browse the repository at this point in the history
* feat: Load any single-cell dataset stored as a `SummarizedExperiment` or `SingleCellExperiment` derivative
* docs: update documentation

Co-authored-by: LTLA <[email protected]>
  • Loading branch information
jkanche and LTLA authored Oct 9, 2022
1 parent 6d6a00b commit 647a9ed
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Our client-side approach has a number of advantages:

## For users

If you have a Matrix Market (`.mtx`) file or HDF5 (tenx V3 or AnnData representation stored as h5ad), you're ready to go.
If you have a Matrix Market (`.mtx`) file or HDF5 (tenx V3 or `AnnData` representation stored as h5ad), or `SummarizedExperiment` (or derivatives like `SingleCellExperiment`) stored as an RDS file, you're ready to go.

1. Launch the application by clicking [**here**](https://www.jkanche.com/kana/).
2. Select the Matrix Market file (this may be Gzip-compressed).
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kana",
"description": "Single cell data analysis in the browser",
"version": "2.3.1",
"version": "2.4.0",
"private": true,
"author": {
"name": "Jayaram Kancherla",
Expand Down Expand Up @@ -32,7 +32,7 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"bakana": "^0.5.0",
"bakana": "^0.6.0",
"d3": "^7.1.1",
"epiviz.gl": "^1.0.2",
"epiviz.scatter.gl": "^0.0.5",
Expand Down
55 changes: 51 additions & 4 deletions src/components/Analysis/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const AnalysisDialog = ({
genes: "Choose feature/gene file",
annotations: "Choose barcode/annotation file",
file: "Choose file...",
rds: "Choose file..."
});

let [stmpInputFiles, ssetTmpInputFiles] = useState({
Expand Down Expand Up @@ -218,9 +219,19 @@ const AnalysisDialog = ({
) {
all_valid = false;
}

if (
x?.rds && !(
inputText[ix]?.rds.toLowerCase().endsWith("rds")
)
) {
all_valid = false;
}

if (x.format === "MatrixMarket") {
if (!x.mtx) all_valid = false;
} else if (x.format === "SummarizedExperiment") {
if (!x.rds) all_valid = false;
} else {
if (!x.h5) all_valid = false;
}
Expand Down Expand Up @@ -323,11 +334,20 @@ const AnalysisDialog = ({
}

if (!x.h5 && (sinputText?.file !== "Choose file...")) all_valid = false;
} else if (
x.format === "SummarizedExperiment") {
if (x?.rds && !(
sinputText?.rds.toLowerCase().endsWith("rds")
)
) {
all_valid = false;
}

if (!x.rds && (sinputText?.file !== "Choose file...")) all_valid = false;
}

// setTmpInputValid(all_valid);
ssetTmpInputValid(all_valid);

}
}
}, [stmpInputFiles]);
Expand Down Expand Up @@ -1103,7 +1123,7 @@ const AnalysisDialog = ({
}}
defaultSelectedTabId={newImportFormat}
>
<Tab id="MatrixMarket" title="Matrix Market file" panel={
<Tab id="MatrixMarket" title="Matrix Market" panel={
<div className="row"
>
<Label className="row-input">
Expand Down Expand Up @@ -1132,7 +1152,7 @@ const AnalysisDialog = ({
</Label>
</div>
} />
<Tab id="10X" title="10x HDF5 matrix" panel={
<Tab id="10X" title="10X HDF5 Matrix" panel={
<div className="row"
>
<Label className="row-input">
Expand Down Expand Up @@ -1166,6 +1186,23 @@ const AnalysisDialog = ({
</Label>
</div>
} />
<Tab id="SummarizedExperiment" title="SummarizedExperiment (RDS)" panel={
<div className="row"
>
<Label className="row-input">
<FileInput style={{
marginTop: '5px'
}}
text={sinputText.rds}
onInputChange={(msg) => {
if (msg.target.files) {
ssetInputText({ ...sinputText, "rds": msg.target.files[0].name });
ssetTmpInputFiles({ ...stmpInputFiles, "rds": msg.target.files[0] })
}
}} />
</Label>
</div>
} />
</Tabs>
</div>
</div>
Expand Down Expand Up @@ -1490,6 +1527,8 @@ const AnalysisDialog = ({
if (row.annotations) {
tname += ` annotations: ${row.annotations.name} `;
}
} else if (row["format"] === "SummarizedExperiment") {
tname += ` file: ${row.rds.name} `;
} else {
tname += ` file: ${row.h5.name} `;
}
Expand Down Expand Up @@ -1948,7 +1987,8 @@ const AnalysisDialog = ({
<ul>
<li>Matrix Market - <code>*.mtx</code> or <code>*.mtx.gz</code></li>
<li>features or genes, <code>*.tsv</code> or <code>*.tsv.gz</code></li>
<li>HDF5 (10x or h5ad) - <code>*.h5</code> or <code>*.hdf5</code> or <code>*.h5ad</code></li>
<li>HDF5 (10X or H5AD) - <code>*.h5</code> or <code>*.hdf5</code> or <code>*.h5ad</code></li>
<li>RDS - <code>*.rds</code></li>
</ul>

Note: Names of dataset must be unique!
Expand Down Expand Up @@ -1977,6 +2017,13 @@ const AnalysisDialog = ({
We will also try to guess which field in the <code>obs</code> annotation contains gene symbols.
</p>

<p>
<strong>A SummarizedExperiment object saved in the RDS (<code>*.rds</code>) format. </strong>
We support any SummarizedExperiment subclass containing a dense or sparse count matrix
(identified as any assay with name starting with "counts", or if none exist, just the first assay).
For a SingleCellExperiment, any alternative experiment with name starting with "hto", "adt" or "antibody" is assumed to represent CITE-seq data.
</p>

<p><strong>Batch correction:</strong> you can now import more than one file to integrate and analyze datasets.
If you only import a single dataset, specify the annotation column that contains the batch information.</p>
</Callout>
Expand Down

0 comments on commit 647a9ed

Please sign in to comment.