Skip to content

Commit 996a43d

Browse files
unknown changes (forgot to commit)
1 parent 23ef82f commit 996a43d

1 file changed

Lines changed: 42 additions & 57 deletions

File tree

src/main/java/cmd/PairwiseSectionAligner.java

Lines changed: 42 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,59 @@
3535
@Command(name = "st-align-pairs", mixinStandardHelpOptions = true, version = "0.2.0", description = "Spatial Transcriptomics as IMages project - align pairs of slices")
3636
public class PairwiseSectionAligner implements Callable<Void> {
3737

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.")
3939
private String containerPath = null;
4040

4141
@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)")
4242
private String datasets = null;
4343

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-
5044
@Option(names = {"-o", "--overwrite"}, required = false, description = "overwrite existing pairwise matches (default: false)")
5145
private boolean overwrite = false;
5246

53-
// TODO: do rendering parameters
47+
//
5448
// 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)")
5651
private double scale = 0.05;
5752

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;
6073

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;
6376

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+
//
6481
// alignment parameters
82+
//
6583
@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)")
6684
private int range = 2;
6785

6886
@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'")
6987
private String genes = null;
7088

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;
7391

7492
@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)")
7593
private double maxEpsilon = -Double.MAX_VALUE;
@@ -206,65 +224,32 @@ public Void call() throws Exception {
206224
System.out.print( g + " ");
207225
System.out.println();
208226

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-
234227
//
235228
// start alignment
236229
//
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-
245230
final SIFTParam p = new SIFTParam();
246231
p.setIntrinsicParameters( SIFTPreset.VERYTHOROUGH );
247232
// TODO: set all parameters
248233
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);
250235
p.minInliersGene = minNumInliersGene;
251236
p.minInliersTotal = minNumInliers;
252237

253238
if ( visualizeResult )
254239
{
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();
262246

263247
AlignTools.defaultGene = renderingGene;
264248
AlignTools.defaultScale = scale;
249+
250+
System.out.println( "Gene used for rendering: " + renderingGene );
265251
}
266252

267-
System.out.println( "Gene used for rendering: " + renderingGene );
268253

269254
System.out.println( "Aligning ... ");
270255

0 commit comments

Comments
 (0)