seqscope / ficture

https://seqscope.github.io/ficture/
Other
27 stars 3 forks source link

Black pixel-level factor image #13

Closed Nick-Eagles closed 1 month ago

Nick-Eagles commented 1 month ago

Hello,

I'm working with Visium HD data and used a combination of spatula convert-sge (for input preparation) and ficture run_together to run FICTURE. The coarse output images (such as analysis/nF12.d_12/figure/nF12.d_12.coarse.png) look reasonable for the two samples I ran the pipeline for, but in both cases the pixel-level image (analysis/nF12.d_12/figure/nF12.d_12.decode.prj_12.r_4_5.pixel.png) show up as a purely black image.

The input preparation piece looks like this (and follows your spatula guide):

#   Get spatial coordinates as a CSV
echo "Converting spatial coords to CSV..."
parquet-tools csv $data_dir/spatial/tissue_positions.parquet \
    | gzip -c > $temp_dir/${this_sample}_tissue_positions.csv.gz

microns_per_pixel=$(
    grep microns_per_pixel $data_dir/spatial/scalefactors_json.json \
        | cut -d ":" -f 2 \
        | tr -d ", "
)

spatula convert-sge \
    --in-sge $data_dir/raw_feature_bc_matrix \
    --pos $temp_dir/${this_sample}_tissue_positions.csv.gz \
    --units-per-um $(python -c "print(1/${microns_per_pixel})") \
    --colnames-count Count \
    --out-tsv $out_dir \
    --icols-mtx 1

## Sort the unsorted output file by the X-coordinate
(gzip -cd $out_dir/transcripts.unsorted.tsv.gz \
    | head -1; gzip -cd $out_dir/transcripts.unsorted.tsv.gz \
    | tail -n +2 | sort -S 1G -gk1) \
    | gzip -c > $out_dir/transcripts.sorted.tsv.gz

The FICTURE command then looks like this:

ficture run_together \
    --in-tsv $in_dir/transcripts.sorted.tsv.gz \
    --in-minmax $in_dir/minmax.tsv \
    --out-dir $out_dir \
    --mu-scale $(python -c "print(1/${microns_per_pixel})") \
    --major-axis X \
    --all

Please let me know if I can provide more information.

Best, -Nick

hyunminkang commented 1 month ago

Can you show the first 10-20 lines of the ....pixel.sorted.tsv.gz file?

hyunminkang commented 1 month ago

Actually, you need to use --mu-scale 1 (or do not use the parameter) because the data is already scaled to micrometer. Can you rerun it?

Nick-Eagles commented 1 month ago

Thanks! I'll try that. In case it's still helpful, this is the first 10 lines of the *pixel.sorted.tsv.gz file:

##K=12;TOPK=3
##BLOCK_SIZE=2000;BLOCK_AXIS=X;INDEX_AXIS=Y
##OFFSET_X=1905.437;OFFSET_Y=6844.177;SIZE_X=6735;SIZE_Y=6735;SCALE=100
#BLOCK  X       Y       K1      K2      K3      P1      P2      P3
0       0       0       0       10      1       1.00e+00        1.00e-05        4.02e-10
0       0       0       0       10      1       1.00e+00        1.00e-08        7.37e-11
0       0       0       0       10      1       1.00e+00        1.00e-09        1.97e-13
0       0       0       0       10      1       1.00e+00        1.00e-12        5.41e-27
0       0       0       0       10      1       1.00e+00        1.00e-13        4.54e-17
0       0       0       0       10      1       1.00e+00        1.01e-04        3.75e-11
hyunminkang commented 1 month ago

It looks that X/Y coordinates in your output seems not recognized. It is possible that --mu-scale parameter in run_together is not working properly. Please let me know if --mu-scale 1 solved the problem.

Nick-Eagles commented 1 month ago

Thank you! --mu-scale 1 indeed solved the problem.