From Desert Sands to Latent Space: A Data-Driven Approach to Fossil Identification

Finding a seashell in the middle of a desert seems like a geological impossibility. For one traveler in the Alghat desert of Saudi Arabia, the discovery of a rock that eerily resembled a seashell—located 500 km from the nearest coastline—sparked a curiosity that couldn't be satisfied by a simple Google search.

While geological records confirm that parts of the Arabian Peninsula were submerged under the sea during the late Jurassic age (~150 million years ago), identifying a specific specimen usually requires a professional paleontologist. Lacking access to one, the finder decided to apply a data science approach to the problem: using morphology and dimensionality reduction to find the closest modern relative of the fossil.

The Challenge of Capturing 'Shape'

To identify the fossil, the goal was to mathematically represent the shape of a shell and define a distance metric to find similar specimens. Utilizing the Zhang et al. shell dataset—containing 7,894 species and 59,244 images—the project faced a significant hurdle: isolating the actual shape from noise.

Any image of a shell can be affected by rotation (pitch, yaw, and roll), scale, and translation. To normalize the data, a strict pipeline was implemented:

  1. Centering: Every shell was centered to the midpoint of the image.
  2. Scaling: The maximum distance from the origin was set to 1 across all images.
  3. Orientation: To handle pitch and yaw, only samples with the shell's opening facing the camera were used. To resolve "roll," the longest radius was used as a reference point and rotated to the right.

Once normalized, the contour of each shell was extracted into 256 points relative to the center, resulting in a 256x2 matrix of (x, y) coordinates. The distance between any two shells was then calculated using the squared Euclidean distance between these contour points.

Mapping the Latent Space with PCA

Working in 256 dimensions is computationally inefficient and impossible to visualize. However, much of this data is redundant; for example, the space of all possible 256-point contours includes shapes that could never exist as real shells. To condense this, Principal Component Analysis (PCA) was employed to map the original dimensions into a smaller "latent space."

The results were striking: the first principal component (PC1) alone retained 56.50% of the variance, and the first two components (PC1 and PC2) captured 67.25%. This means a shell's general shape can be described by just two numbers.

By analyzing shells at opposite ends of the PC1 dimension, the author discovered that PC1 represents "pointiness." More than half of the variance in shell shapes is simply a matter of how pointy or round they are. PC2 appears to capture symmetry or mass distribution along the vertical axis.

Findings and Geological Context

When the Alghat fossil was projected into this latent space, the closest match was Sphincterochila candidissima. However, a chronological discrepancy emerged: S. candidissima is relatively young, with the earliest fossils dating back only 38 million years, whereas the Alghat region's marine deposits date back to the Jurassic period.

This suggests that while the shapes are nearly identical, they are not the same species. This is a classic example of convergent evolution, where two unrelated species evolve similar physical traits because they face similar environmental pressures.

Community Perspectives and Counterpoints

The project sparked a lively discussion among the technical and scientific community on Hacker News. While many praised the DIY data science approach, others pointed out the limitations of morphology-based identification.

Morphological Limitations

Some users noted that shell shape alone is often insufficient for precise lineage. As one commenter, @purplehat_, noted:

"There's a lot more to morphology than just the shape of the shell... you've got a gastropod, so it would be good to pay special attention to the peristome and siphonal canal."

Alternative Identifications

While the PCA tool pointed toward S. candidissima, other community members suggested the fossil might be Ampullospira, a genus documented in Saudi Arabia that matches both the location and the Middle-Upper Jurassic age of the region.

The Ubiquity of Marine Fossils

Though the find felt "impossible" to the author, commenters reminded the community that marine fossils are common in unexpected places. From the sandstone of St. Stephen's Cathedral in Vienna to the very summit of Mt. Everest, marine limestone serves as a permanent record of the Earth's shifting tectonic plates and ancient coastlines.

Conclusion

This experiment demonstrates the power of dimensionality reduction in making sense of complex biological data. While it may not replace the expertise of a paleontologist—who would look at sediment and internal anatomy—it provides a fascinating way to visualize the "space" of biological forms and discover eerie similarities across millions of years of evolution.

Sources