Class MexMatrixWriter
java.lang.Object
ubic.gemma.core.datastructure.matrix.io.MexMatrixWriter
- All Implemented Interfaces:
ExpressionDataMatrixWriter<SingleCellExpressionDataMatrix<?>,,SingleCellExpressionDataVector> SingleCellExpressionDataMatrixWriter
Writes
SingleCellExpressionDataMatrix to the 10x MEX format.
The data is written as a TAR archive containing the following entries for each bioassay: {bioAssayName}/barcodes.tsv,
{bioAssayName}/features.tsv, {bioAssayName}/matrix.mtx. If using the directory output, individual
files are compressed and will have a .gz extension.
- Author:
- poirigui
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetAutoFlush(boolean autoFlush) Flush every time a complete line is written.voidsetExecutorService(Executor executorService) Executor to use to write MEX files in parallel.voidsetScaleType(ScaleType scaleType) Set the scale type to use when writing the matrix.voidsetUseEnsemblIds(boolean useEnsemblIds) Use Ensembl gene IDs instead of gene symbols.intwrite(Stream<SingleCellExpressionDataVector> vectors, int numVecs, Map<BioAssay, Long> nnzBySample, Map<CompositeSequence, Set<Gene>> cs2gene, Path outputDir) Writes a stream of vectors to a directory.intwrite(SingleCellExpressionDataMatrix<?> matrix, Class<? extends SingleCellExpressionDataVector> vectorType, OutputStream stream) Write the matrix to the given output stream.intwrite(SingleCellExpressionDataMatrix<?> matrix, Class<? extends SingleCellExpressionDataVector> vectorType, Writer stream) Write the matrix to the given writer.intwrite(SingleCellExpressionDataMatrix<?> matrix, Map<CompositeSequence, Set<Gene>> cs2gene, OutputStream stream) Write a MEX matrix as a TAR archive to the given output stream.intwrite(SingleCellExpressionDataMatrix<?> matrix, Map<CompositeSequence, Set<Gene>> cs2gene, Path outputDir) Write a matrix to a directory.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ubic.gemma.core.datastructure.matrix.io.SingleCellExpressionDataMatrixWriter
write, write
-
Constructor Details
-
MexMatrixWriter
public MexMatrixWriter()
-
-
Method Details
-
write
public int write(SingleCellExpressionDataMatrix<?> matrix, Class<? extends SingleCellExpressionDataVector> vectorType, Writer stream) throws IOException Description copied from interface:ExpressionDataMatrixWriterWrite the matrix to the given writer.- Specified by:
writein interfaceExpressionDataMatrixWriter<SingleCellExpressionDataMatrix<?>,SingleCellExpressionDataVector> - Parameters:
vectorType- the type of vectors to write. This helps the writer determine how theQuantitationTypeof the matrix should be interpreted.- Returns:
- the number of vectors written
- Throws:
IOException
-
write
public int write(SingleCellExpressionDataMatrix<?> matrix, Class<? extends SingleCellExpressionDataVector> vectorType, OutputStream stream) throws IOException Description copied from interface:ExpressionDataMatrixWriterWrite the matrix to the given output stream.- Specified by:
writein interfaceExpressionDataMatrixWriter<SingleCellExpressionDataMatrix<?>,SingleCellExpressionDataVector> - Returns:
- the number of vectors written
- Throws:
IOException
-
write
public int write(SingleCellExpressionDataMatrix<?> matrix, @Nullable Map<CompositeSequence, Set<Gene>> cs2gene, OutputStream stream) throws IOExceptionWrite a MEX matrix as a TAR archive to the given output stream.- Throws:
IOException
-
write
public int write(SingleCellExpressionDataMatrix<?> matrix, @Nullable Map<CompositeSequence, Set<Gene>> cs2gene, Path outputDir) throws IOExceptionWrite a matrix to a directory.- Throws:
IOException
-
write
public int write(Stream<SingleCellExpressionDataVector> vectors, int numVecs, Map<BioAssay, Long> nnzBySample, @Nullable Map<CompositeSequence, throws IOExceptionSet<Gene>> cs2gene, Path outputDir) Writes a stream of vectors to a directory.- Parameters:
vectors- a stream of vectorsnumVecs- the total number of vectors to writennzBySample- the number of non-zeroes by samplecs2gene- a mapping of design elements to their corresponding gene(s)- Throws:
IOException
-
setAutoFlush
public void setAutoFlush(boolean autoFlush) Description copied from interface:ExpressionDataMatrixWriterFlush every time a complete line is written.This is not very efficient, but it can be used to view the output of a matrix as it is being written.
- Specified by:
setAutoFlushin interfaceExpressionDataMatrixWriter<SingleCellExpressionDataMatrix<?>,SingleCellExpressionDataVector>
-
setScaleType
Description copied from interface:ExpressionDataMatrixWriterSet the scale type to use when writing the matrix.When null, the original values must be used.
- Specified by:
setScaleTypein interfaceExpressionDataMatrixWriter<SingleCellExpressionDataMatrix<?>,SingleCellExpressionDataVector>
-
setUseEnsemblIds
public void setUseEnsemblIds(boolean useEnsemblIds) Use Ensembl gene IDs instead of gene symbols. -
setExecutorService
Executor to use to write MEX files in parallel.
-