Skip to content

Commit 3999b68

Browse files
committed
Gzip metadata for seurat objects
1 parent f10c26d commit 3999b68

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

singlecell/resources/chunks/Functions.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ saveData <- function(seuratObj, datasetId) {
8181

8282
logger::log_info(paste0('Saving RDS file: ', fn, ' with ', ncol(seuratObj), ' cells'))
8383
barcodeFile <- paste0(outputPrefix, '.', datasetIdForFile, '.cellBarcodes.csv')
84-
metaFile <- paste0(outputPrefix, '.', datasetIdForFile, '.seurat.meta.txt')
84+
metaFile <- paste0(outputPrefix, '.', datasetIdForFile, '.seurat.meta.txt.gz')
8585

8686
saveRDS(seuratObj, file = fn)
8787

singlecell/src/org/labkey/singlecell/CellHashingServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ public File getMetaTableFromSeurat(File seuratObj)
15731573

15741574
public File getMetaTableFromSeurat(File seuratObj, boolean throwIfNotFound)
15751575
{
1576-
File barcodes = new File(seuratObj.getParentFile(), seuratObj.getName().replaceAll("seurat.rds$", "seurat.meta.txt"));
1576+
File barcodes = new File(seuratObj.getParentFile(), seuratObj.getName().replaceAll("seurat.rds$", "seurat.meta.txt.gz"));
15771577
if (throwIfNotFound && !barcodes.exists())
15781578
{
15791579
throw new IllegalArgumentException("Unable to find expected metadata file. This might indicate the seurat object was created with an older version of the pipeline. Expected: " + barcodes.getPath());

singlecell/src/org/labkey/singlecell/pipeline/singlecell/UpdateSeuratPrototype.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.labkey.api.sequenceanalysis.pipeline.SequenceOutputHandler;
1616
import org.labkey.api.singlecell.pipeline.SeuratToolParameter;
1717
import org.labkey.api.singlecell.pipeline.SingleCellStep;
18+
import org.labkey.singlecell.CellHashingServiceImpl;
1819
import org.labkey.singlecell.SingleCellSchema;
1920

2021
import java.io.File;
@@ -140,6 +141,24 @@ public Output execute(SequenceOutputHandler.JobContext ctx, List<SeuratObjectWra
140141
}
141142

142143
FileUtils.moveFile(wrapper.getFile(), toReplace);
144+
145+
// Also metadata:
146+
File meta = CellHashingServiceImpl.get().getMetaTableFromSeurat(wrapper.getFile());
147+
File metaOrig = CellHashingServiceImpl.get().getMetaTableFromSeurat(toReplace);
148+
if (metaOrig.exists())
149+
{
150+
metaOrig.delete();
151+
}
152+
FileUtils.moveFile(meta, metaOrig);
153+
154+
// Also cellbarcodes:
155+
File cellbarcodes = CellHashingServiceImpl.get().getCellBarcodesFromSeurat(wrapper.getFile());
156+
File cellbarcodesOrig = CellHashingServiceImpl.get().getCellBarcodesFromSeurat(toReplace);
157+
if (cellbarcodesOrig.exists())
158+
{
159+
cellbarcodesOrig.delete();
160+
}
161+
FileUtils.moveFile(cellbarcodes, cellbarcodesOrig);
143162
}
144163
catch (IOException e)
145164
{

0 commit comments

Comments
 (0)