|
35 | 35 | @Command(name = "st-align-pairs", mixinStandardHelpOptions = true, version = "0.2.0", description = "Spatial Transcriptomics as IMages project - align pairs of slices") |
36 | 36 | public class PairwiseSectionAligner implements Callable<Void> { |
37 | 37 |
|
38 | | - @Option(names = {"-c", "--container"}, required = true, description = "input N5 container path, e.g. -i /home/ssq.n5.") |
| 38 | + @Option(names = {"-i", "--input"}, required = true, description = "input N5 container path, e.g. -i /home/ssq.n5.") |
39 | 39 | private String containerPath = null; |
40 | 40 |
|
41 | 41 | @Option(names = {"-d", "--datasets"}, required = false, description = "ordered, comma separated list of one or more datasets, e.g. -d 'Puck_180528_20,Puck_180528_22' (default: all, in order as saved in N5 metadata)") |
42 | 42 | private String datasets = null; |
43 | 43 |
|
44 | | - //@Option(names = {"-l", "--loadGenes"}, required = false, description = "load a plain text file with gene names") |
45 | | - //private String loadGenes = null; |
46 | | - |
47 | | - //@Option(names = {"-s", "--saveGenes"}, required = false, description = "save a plain text file with gene names that were used (can be later imported with -l)") |
48 | | - //private String saveGenes = null; |
49 | | - |
50 | 44 | @Option(names = {"-o", "--overwrite"}, required = false, description = "overwrite existing pairwise matches (default: false)") |
51 | 45 | private boolean overwrite = false; |
52 | 46 |
|
53 | | - // TODO: do rendering parameters |
| 47 | + // |
54 | 48 | // rendering parameters |
55 | | - @Option(names = {"-s", "--scale"}, required = false, description = "scaling factor rendering the coordinates into images, which is highly sample-dependent (default: 0.05 for slideseq data)") |
| 49 | + // |
| 50 | + @Option(names = {"-s", "--scale"}, required = false, description = "initial scaling factor for rendering the coordinates into images, can be changed interactively (default: 0.05 for slideseq data)") |
56 | 51 | private double scale = 0.05; |
57 | 52 |
|
58 | | - @Option(names = {"-sf", "--smoothnessFactor"}, required = false, description = "factor for the sigma of the gaussian used for rendering, corresponds to smoothness, e.g -sf 2.0 (default: 4.0)") |
59 | | - private double smoothnessFactor = 4.0; |
| 53 | + @Option(names = {"-bmin", "--brightnessMin"}, required = false, description = "min initial brightness relative to the maximal value + overall min intensity (default: 0.0)") |
| 54 | + private double brightnessMin = 0.0; |
| 55 | + |
| 56 | + @Option(names = {"-bmax", "--brightnessMax"}, required = false, description = "max initial brightness relative to the maximal value (default: 0.5)") |
| 57 | + private double brightnessMax = 0.5; |
| 58 | + |
| 59 | + @Option(names = {"-rf", "--renderingFactor"}, required = false, description = "factor for the amount of filtering or radius used for rendering, corresponds to smoothness for Gauss, e.g -rf 2.0 (default: 1.0)") |
| 60 | + private double renderingFactor = 1.0; |
| 61 | + |
| 62 | + @Option(names = {"--rendering"}, required = false, description = "inital rendering type (Gauss, Mean, NearestNeighbor, Linear), e.g --rendering Gauss (default: Gauss)") |
| 63 | + private Rendering rendering = Rendering.Gauss; |
| 64 | + |
| 65 | + @Option(names = {"-sk", "--skip"}, required = false, description = "skips the first N genes when selecting by highest entropy, as they can be outliers (default: 10)") |
| 66 | + private int skipFirstNGenes = 10; |
| 67 | + |
| 68 | + @Option(names = {"--ffSingleSpot"}, required = false, description = "filter single spots using the median distance between all spots as threshold, e.g. --ffSingleSpot 1.5 (default: no filtering)") |
| 69 | + private Double ffSingleSpot = null; |
| 70 | + |
| 71 | + @Option(names = {"--ffMedian"}, required = false, description = "median-filter all spots using a given radius, e.g --ffMedian 5.0 (default: no filtering)") |
| 72 | + private Double ffMedian = null; |
60 | 73 |
|
61 | | - @Option(names = {"--renderingGene"}, required = false, description = "gene used for visualizing the results, e.g. renderingGene Calm2 (default: Calm2 if present, else first gene in the list)") |
62 | | - private String renderingGene = null; |
| 74 | + @Option(names = {"--ffGauss"}, required = false, description = "Gauss-filter all spots using a given radius, e.g --ffGauss 2.0 (default: no filtering)") |
| 75 | + private Double ffGauss = null; |
63 | 76 |
|
| 77 | + @Option(names = {"--ffMean"}, required = false, description = "mean/avg-filter all spots using a given radius, e.g --ffMean 2.5 (default: no filtering)") |
| 78 | + private Double ffMean = null; |
| 79 | + |
| 80 | + // |
64 | 81 | // alignment parameters |
| 82 | + // |
65 | 83 | @Option(names = {"-r", "--range"}, required = false, description = "range in which pairs of datasets will be aligned, therefore the order in -d is important (default: 2)") |
66 | 84 | private int range = 2; |
67 | 85 |
|
68 | 86 | @Option(names = {"-g", "--genes"}, required = false, description = "comma separated list of one or more genes to be used (on top of numGenes, which can be set to 0 if only selected genes should be used), e.g. -g 'Calm2,Hpca,Ptgds'") |
69 | 87 | private String genes = null; |
70 | 88 |
|
71 | | - @Option(names = {"-n", "--numGenes"}, required = false, description = "use N number of genes that have the highest entropy (default: 100)") |
72 | | - private int numGenes = 100; |
| 89 | + @Option(names = {"-n", "--numGenes"}, required = false, description = "initial number of genes for alignment that have the highest entropy (default: 10)") |
| 90 | + private int numGenes = 10; |
73 | 91 |
|
74 | 92 | @Option(names = {"-e", "--maxEpsilon"}, required = false, description = "maximally allowed alignment error (in global space, independent of scaling factor) for SIFT on a 2D rigid model (default: 10 times the average distance between sequenced locations)") |
75 | 93 | private double maxEpsilon = -Double.MAX_VALUE; |
@@ -206,65 +224,32 @@ public Void call() throws Exception { |
206 | 224 | System.out.print( g + " "); |
207 | 225 | System.out.println(); |
208 | 226 |
|
209 | | - /* |
210 | | - if ( loadGenes != null && loadGenes.length() > 0 ) |
211 | | - { |
212 | | - final File file = new File( loadGenes ); |
213 | | - if ( !file.exists() ) |
214 | | - { |
215 | | - System.out.println( "File for loading genes '" + file.getAbsolutePath() + "' does not exist. stopping."); |
216 | | - return null; |
217 | | - } |
218 | | - |
219 | | - for ( final String gene : TextFileIO.loadGenes( file, new HashSet<>( stData1.getGeneNames() ), new HashSet<>( stData2.getGeneNames() ) ) ) |
220 | | - genesToTest.add( gene ); |
221 | | - |
222 | | - System.out.println( "Loaded genes, number of genes now " + genesToTest.size() ); |
223 | | - } |
224 | | - |
225 | | - System.out.println( "Total number of genes: " + genesToTest.size() ); |
226 | | - |
227 | | - if ( saveGenes != null && saveGenes.length() > 0 ) |
228 | | - { |
229 | | - TextFileIO.saveGenes( new File( saveGenes ), genesToTest ); |
230 | | - System.out.println( "Saved genes to file " + new File( saveGenes ).getAbsolutePath() ); |
231 | | - } |
232 | | - */ |
233 | | - |
234 | 227 | // |
235 | 228 | // start alignment |
236 | 229 | // |
237 | | - |
238 | | - //final double scale = 0.05; //global scaling |
239 | | - //final double smoothnessFactor = 4.0; |
240 | | - |
241 | | - //final double maxEpsilon = 250; |
242 | | - //final int minNumInliers = 30; |
243 | | - //final int minNumInliersPerGene = 5; |
244 | | - |
245 | 230 | final SIFTParam p = new SIFTParam(); |
246 | 231 | p.setIntrinsicParameters( SIFTPreset.VERYTHOROUGH ); |
247 | 232 | // TODO: set all parameters |
248 | 233 | final List< FilterFactory< DoubleType, DoubleType > > filterFactories = null; |
249 | | - p.setDatasetParameters(maxEpsilon, scale, 1024, filterFactories, Rendering.Gauss, smoothnessFactor, 0.0, 1.0); |
| 234 | + //p.setDatasetParameters(maxEpsilon, scale, 1024, filterFactories, Rendering.Gauss, smoothnessFactor, 0.0, 1.0); |
250 | 235 | p.minInliersGene = minNumInliersGene; |
251 | 236 | p.minInliersTotal = minNumInliers; |
252 | 237 |
|
253 | 238 | if ( visualizeResult ) |
254 | 239 | { |
255 | | - if ( renderingGene == null ) |
256 | | - { |
257 | | - if ( genesToTest.contains( "Calm2" ) ) |
258 | | - renderingGene = "Calm2"; |
259 | | - else |
260 | | - renderingGene = genesToTest.iterator().next(); |
261 | | - } |
| 240 | + String renderingGene; |
| 241 | + |
| 242 | + if ( genesToTest.contains( "Calm2" ) ) |
| 243 | + renderingGene = "Calm2"; |
| 244 | + else |
| 245 | + renderingGene = genesToTest.iterator().next(); |
262 | 246 |
|
263 | 247 | AlignTools.defaultGene = renderingGene; |
264 | 248 | AlignTools.defaultScale = scale; |
| 249 | + |
| 250 | + System.out.println( "Gene used for rendering: " + renderingGene ); |
265 | 251 | } |
266 | 252 |
|
267 | | - System.out.println( "Gene used for rendering: " + renderingGene ); |
268 | 253 |
|
269 | 254 | System.out.println( "Aligning ... "); |
270 | 255 |
|
|
0 commit comments