-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSTDataImgLib2.java
More file actions
119 lines (97 loc) · 3.08 KB
/
Copy pathSTDataImgLib2.java
File metadata and controls
119 lines (97 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package data;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.RealInterval;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.real.DoubleType;
/**
* An implementation of STData that uses ImgLib2 datastructures to hold the actual data
*
* @author spreibi
*
*/
public class STDataImgLib2 extends STDataAbstract
{
/**
* a 2d datastructure that holds all sequenced locations, size: [numLocations x numDimensions]
*/
private final RandomAccessibleInterval< DoubleType > locations;
/**
* a 2d datastructure that holds all expression values, size: [numGenes x numLocations]
*/
private final RandomAccessibleInterval< DoubleType > exprValues;
private final List< String > geneNames, barcodes;
private final HashMap< String, Integer > geneLookup;
private final Map<String, RandomAccessibleInterval<? extends NativeType< ? >>> annotations;
private final Map<String, RandomAccessibleInterval<? extends NativeType< ? >>> geneAnnotations;
private RealInterval realInterval;
public static class STDataImgLib2Factory
{
public RandomAccessibleInterval< DoubleType > locations, exprValues;
public List< String > geneNames, barcodes;
public HashMap< String, Integer > geneLookup;
}
public STDataImgLib2( final STDataImgLib2Factory factory )
{
this( factory.locations, factory.exprValues, factory.geneNames, factory.barcodes, factory.geneLookup );
}
public STDataImgLib2(
final RandomAccessibleInterval< DoubleType > locations,
final RandomAccessibleInterval< DoubleType > exprValues,
final List< String > geneNames,
final List< String > barcodes,
final HashMap< String, Integer > geneLookup )
{
super( (int)locations.dimension( 1 ), (int)locations.dimension( 0 ), (int)exprValues.dimension( 0 ) );
this.locations = locations;
this.exprValues = exprValues;
this.geneNames = geneNames;
this.barcodes = barcodes;
this.geneLookup = geneLookup;
this.annotations = new HashMap<>();
this.geneAnnotations = new HashMap<>();
this.realInterval = STDataUtils.computeRealInterval( this );
}
@Override
public Map<String, RandomAccessibleInterval<? extends NativeType< ? >>> getAnnotations()
{
return annotations;
}
@Override
public Map<String, RandomAccessibleInterval<? extends NativeType< ? >>> getGeneAnnotations()
{
return geneAnnotations;
}
@Override
protected RealInterval getLocationRealInterval()
{
return realInterval;
}
@Override
public void setLocations( final List< double[] > locations )
{
STDataText.setLocations( locations, this.locations );
this.realInterval = STDataUtils.computeRealInterval( this );
}
@Override
public int getIndexForGene( final String gene )
{
return geneLookup.get( gene );
}
@Override
public List< String > getGeneNames() { return geneNames; }
@Override
public List< String > getBarcodes() { return barcodes; }
@Override
public RandomAccessibleInterval< DoubleType > getAllExprValues()
{
return exprValues;
}
@Override
public RandomAccessibleInterval< DoubleType > getLocations()
{
return locations;
}
}