Skip to content

Commit d470dc5

Browse files
committed
Deal with (=explicitly ignore) string annotations
1 parent 838d94a commit d470dc5

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

src/main/java/cmd/PairwiseSectionAligner.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,12 @@ public Void call() throws Exception {
203203
logger.debug("Gene annotation '{}' was found for {}. Omitting.", stdevLabel, datasetName);
204204
continue;
205205
}
206+
if (numGenes == 0) {
207+
continue;
208+
}
206209

207-
final boolean computeStdev = (numGenes > 0 && entropyPath == null);
208210
final RandomAccessibleInterval<DoubleType> entropyValues;
209-
if (computeStdev) {
211+
if (entropyPath == null) {
210212
logger.info("Computing standard deviation of genes for {} (may take a while)", datasetName);
211213
entropyValues = ExtractGeneLists.computeOrderedEntropy(stData.data(), Entropy.STDEV, numThreads);
212214
} else {
@@ -215,7 +217,7 @@ public Void call() throws Exception {
215217
}
216218
stData.data().getGeneAnnotations().put(stdevLabel, entropyValues);
217219

218-
if (computeStdev) {
220+
if (entropyPath == null) {
219221
try {
220222
container.openDataset(datasetName).updateStoredGeneAnnotations(stData.data().getGeneAnnotations());
221223
} catch (IOException e) {

src/main/java/io/SpatialDataIO.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,21 @@ public STDataAssembly readData() throws IOException {
165165
AffineTransform2D transform = new AffineTransform2D();
166166
readAndSetTransformation(reader, transform, transformFieldName);
167167

168-
for (final String annotationLabel : detectAnnotations(reader))
169-
stData.getAnnotations().put(annotationLabel, readAnnotations(reader, annotationLabel));
168+
for (final String annotationLabel : detectAnnotations(reader)) {
169+
try {
170+
stData.getAnnotations().put(annotationLabel, readAnnotations(reader, annotationLabel));
171+
} catch (Exception e) {
172+
logger.warn("Could not read annotation '{}'. Skipping", annotationLabel);
173+
}
174+
}
170175

171-
for (final String geneAnnotationLabel : detectGeneAnnotations(reader))
172-
stData.getGeneAnnotations().put(geneAnnotationLabel, readGeneAnnotations(reader, geneAnnotationLabel));
176+
for (final String geneAnnotationLabel : detectGeneAnnotations(reader)) {
177+
try {
178+
stData.getGeneAnnotations().put(geneAnnotationLabel, readGeneAnnotations(reader, geneAnnotationLabel));
179+
} catch (Exception e) {
180+
logger.warn("Could not read annotation '{}'. Skipping", geneAnnotationLabel);
181+
}
182+
}
173183

174184
logger.debug("Loading took {} ms.", System.currentTimeMillis() - time);
175185
logger.debug("Metadata: dims={}, numLocations={}, numGenes={}, size(locations)={}, size(exprValues)={}",

0 commit comments

Comments
 (0)