Skip to content

Example: dimensionality reduction

Maciej Długosz edited this page May 11, 2026 · 1 revision

Example: revealing sex dimorphism with dimensionality reduction

To sketch dimorphism of sex for the African Turquoise Killifish liver tissue, the user may prepare an input samples.txt file of samples:

SRR22013784 SRR22013784_1_val_1.fq.gz SRR22013784_2_val_2.fq.gz
SRR22013785 SRR22013785_1_val_1.fq.gz SRR22013785_2_val_2.fq.gz
SRR22013786 SRR22013786_1_val_1.fq.gz SRR22013786_2_val_2.fq.gz
SRR22013780 SRR22013780_1_val_1.fq.gz SRR22013780_2_val_2.fq.gz
SRR22013769 SRR22013769_1_val_1.fq.gz SRR22013769_2_val_2.fq.gz
SRR22013763 SRR22013763_1_val_1.fq.gz SRR22013763_2_val_2.fq.gz
SRR22013779 SRR22013779_1_val_1.fq.gz SRR22013779_2_val_2.fq.gz
SRR22013793 SRR22013793_1_val_1.fq.gz SRR22013793_2_val_2.fq.gz
SRR22013782 SRR22013782_1_val_1.fq.gz SRR22013782_2_val_2.fq.gz
SRR22013774 SRR22013774_1_val_1.fq.gz SRR22013774_2_val_2.fq.gz
SRR22013762 SRR22013762_1_val_1.fq.gz SRR22013762_2_val_2.fq.gz
SRR22013770 SRR22013770_1_val_1.fq.gz SRR22013770_2_val_2.fq.gz
SRR22013775 SRR22013775_1_val_1.fq.gz SRR22013775_2_val_2.fq.gz
SRR22013765 SRR22013765_1_val_1.fq.gz SRR22013765_2_val_2.fq.gz
SRR22013787 SRR22013787_1_val_1.fq.gz SRR22013787_2_val_2.fq.gz
SRR22013789 SRR22013789_1_val_1.fq.gz SRR22013789_2_val_2.fq.gz

and then perform dimensionality reduction with the following command line:

./mkmc                                           (1)
 -k 30 -m 16 \                                   (2)
--thr-rat 1.0 --thr 1 \                          (3)
--flt GCF_001465895.1_Nfu_20140520_genomic.fna \ (4)
 -t 32 \                                         (5)
--cs 1000000000 \                                (6)
 -n freq \                                       (7)
--pca --umap \                                   (8)
-- samples.txt GSE216369_liver_trimmed tmp \     (9)

The consecutive lines mean as follows:

  1. Run MKMC.
  2. Count 30-mers; k-mer counting should not use more than 16 GB of memory; by default, samples data is stored in FASTQ files (see Building a matrix for non-FASTQ input files).
  3. Exclude k-mers from the matrix which ones has no counts in all the samples at least 1; i.e. keep k-mers present at least once in all the samples (see Filtering k-mers along with building the matrix).
  4. Keep only k-mers which are present in GCF_001465895.1_Nfu_20140520_genomic.fna file (see Filtering k-mers along with building the matrix). Here we pass the file with the whole genome to consider only k-mers present there.
  5. Use 32 threads.
  6. Set the maximal number of count to $10^9$, instead of $65535$.
  7. Normalize counts with frequency count method, but do not save them to the disk (rather use them as PCA and UMAP input, see Normalizing counts).
  8. Reduce the number of counts dimensions from $(\text{no. of k-mers})\times{}16$ to $2\times{}16$ with PCA and UMAP methods in a single run (see Dimensionality reduction).
  9. Pass to MKMC the file with samples, an output file name template (GSE216369_liver_trimmed) and a temporary directory (tmp). Note the space after the two dashes.

To trim the input reads (as in the example), the user may use e.g. trim_galore:

./trim_galore -j 8 --fastqc --fastqc_args "--outdir fastqc/SRR22013784" --gzip --output_dir . --paired SRR22013784_1.fastq.gz SRR22013784_2.fastq.gz

Clone this wiki locally