Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 3.22)

# -----------------------------------------------------------------------------
# CrossSpeciesComparisonGeneDetectPlugin
# XSCGeneDetectPlugin
# -----------------------------------------------------------------------------
PROJECT("CrossSpeciesComparisonGeneDetectPlugin")
PROJECT("XSCGeneDetectPlugin")

# -----------------------------------------------------------------------------
# CMake Options
Expand Down Expand Up @@ -36,11 +36,16 @@ find_package(ManiVault COMPONENTS Core PointData ClusterData CONFIG QUIET)
# -----------------------------------------------------------------------------
# Define the plugin sources
set(PLUGIN_SOURCES
src/CrossSpeciesComparisonGeneDetectPlugin.h
src/CrossSpeciesComparisonGeneDetectPlugin.cpp
src/XSCGeneDetectPlugin.h
src/XSCGeneDetectPlugin.cpp
src/SettingsAction.h
src/SettingsAction.cpp
src/CrossSpeciesComparisonGeneDetectPlugin.json
src/SettingsAction.Ui.inl
src/SettingsAction.Analysis.inl
src/SettingsAction.Data.inl
src/SettingsAction.Tree.inl
src/SettingsAction.Serialization.inl
src/XSCGeneDetectPlugin.json
)
set(LIBS
src/lib/Clustering/fastcluster.cpp
Expand All @@ -56,13 +61,13 @@ set(LIBS
)

set(PLUGIN_MOC_HEADERS
src/CrossSpeciesComparisonGeneDetectPlugin.h
src/XSCGeneDetectPlugin.h
)
set(AUX
res/CrossSpeciesComparisonGeneDetect_chart.qrc
res/XSCGeneDetect_chart.qrc
)

qt6_add_resources(RESOURCE_FILES res/CrossSpeciesComparisonGeneDetect_chart.qrc)
qt6_add_resources(RESOURCE_FILES res/XSCGeneDetect_chart.qrc)

source_group(Plugin FILES ${PLUGIN_SOURCES})
source_group(LibFiles FILES ${LIBS})
Expand Down Expand Up @@ -102,19 +107,19 @@ target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Concurrent )


# Allow override of plugin library path from the build system
set(CROSSSPECIESCOMPARISONTREEDATA_LINK_LIBRARY "${CROSSSPECIESCOMPARISONTREEDATA_LINK_LIBRARY}" CACHE STRING "Path to CrossSpeciesComparisonTreeData library")
if(NOT CROSSSPECIESCOMPARISONTREEDATA_LINK_LIBRARY)
set(XSCTREEDATA_LINK_LIBRARY "${XSCTREEDATA_LINK_LIBRARY}" CACHE STRING "Path to XSCTreeData library")
if(NOT XSCTREEDATA_LINK_LIBRARY)
set(CSCTDPLUGIN_LINK_PATH "${MV_CSCTD_INSTALL_DIR}/$<CONFIGURATION>/$<IF:$<CXX_COMPILER_ID:MSVC>,lib,Plugins>")
set(MV_LINK_SUFFIX $<IF:$<CXX_COMPILER_ID:MSVC>,${CMAKE_LINK_LIBRARY_SUFFIX},${CMAKE_SHARED_LIBRARY_SUFFIX}>)
set(CROSSSPECIESCOMPARISONTREEDATA_LINK_LIBRARY "${CSCTDPLUGIN_LINK_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}CrossSpeciesComparisonTreeData${MV_LINK_SUFFIX}")
set(XSCTREEDATA_LINK_LIBRARY "${CSCTDPLUGIN_LINK_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}XSCTreeData${MV_LINK_SUFFIX}")
endif()

# Link to ManiVault and data plugins
target_link_libraries(${PROJECT_NAME} PRIVATE ManiVault::Core)
target_link_libraries(${PROJECT_NAME} PRIVATE ManiVault::PointData)
target_link_libraries(${PROJECT_NAME} PRIVATE ManiVault::ClusterData)

target_link_libraries(${PROJECT_NAME} PRIVATE "${CROSSSPECIESCOMPARISONTREEDATA_LINK_LIBRARY}")
target_link_libraries(${PROJECT_NAME} PRIVATE "${XSCTREEDATA_LINK_LIBRARY}")

# -----------------------------------------------------------------------------
# Target installation
Expand Down
167 changes: 167 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.


This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

0. Additional Definitions.

As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

2. Conveying Modified Versions.

If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or

b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.

3. Object Code Incorporating Material from Library Header Files.

The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the object code with a copy of the GNU GPL and this license
document.

4. Combined Works.

You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.

c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.

d) Do one of the following:

0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.

1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.

e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)

5. Combined Libraries.

You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.

b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.

6. Revised Versions of the GNU Lesser General Public License.

The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

END OF TERMS AND CONDITIONS
108 changes: 107 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,107 @@
CrossSpeciesComparisonGeneDetectPlugin
# XSCGeneDetectPlugin

`XSCGeneDetectPlugin` is a ManiVault view plugin for exploring cross-species gene expression differences from point-based single-cell style datasets.

The plugin is designed for workflows where a user:

- selects a subset of cells in an embedding or scatterplot,
- compares selected versus non-selected cells across species,
- ranks genes by differential expression,
- inspects per-species statistics in tables,
- and projects those statistics back onto phylogenetic tree and scatterplot views.

## What The Plugin Does

At a high level, the plugin combines five pieces of information:

- a main expression dataset (`Points`),
- a low-dimensional embedding dataset (`Points`),
- a species assignment dataset (`Cluster`),
- one or more hierarchy / cell-type cluster datasets (`Cluster`),
- and a reference phylogenetic tree dataset (`XSCTree`).

From these inputs, it computes:

- mean expression per gene and species,
- selected-versus-non-selected expression statistics,
- top-N ranked genes per species,
- species-level abundance summaries within selected hierarchy branches,
- table models for ranked genes and species summaries,
- optional scatterplot coloring datasets,
- and optional tree payloads for hierarchy-specific exploration.

## Repository Layout

- [CMakeLists.txt](E:/Coding/DevBundle/GenerateTHESISImages/source/XSCGeneDetectPlugin/CMakeLists.txt): CMake target definition and ManiVault/Qt integration.
- [src/XSCGeneDetectPlugin.h](E:/Coding/DevBundle/GenerateTHESISImages/source/XSCGeneDetectPlugin/src/XSCGeneDetectPlugin.h): plugin class declaration.
- [src/XSCGeneDetectPlugin.cpp](E:/Coding/DevBundle/GenerateTHESISImages/source/XSCGeneDetectPlugin/src/XSCGeneDetectPlugin.cpp): plugin wiring, view integration, table rendering, and scatterplot/tree coordination.
- [src/SettingsAction.h](E:/Coding/DevBundle/GenerateTHESISImages/source/XSCGeneDetectPlugin/src/SettingsAction.h): main state container and action declarations.
- [src/SettingsAction.cpp](E:/Coding/DevBundle/GenerateTHESISImages/source/XSCGeneDetectPlugin/src/SettingsAction.cpp): shared helpers and compilation unit for the split inline implementation.
- [src/SettingsAction.Ui.inl](E:/Coding/DevBundle/GenerateTHESISImages/source/XSCGeneDetectPlugin/src/SettingsAction.Ui.inl): UI/action wiring.
- [src/SettingsAction.Analysis.inl](E:/Coding/DevBundle/GenerateTHESISImages/source/XSCGeneDetectPlugin/src/SettingsAction.Analysis.inl): main analysis and ranking logic.
- [src/SettingsAction.Data.inl](E:/Coding/DevBundle/GenerateTHESISImages/source/XSCGeneDetectPlugin/src/SettingsAction.Data.inl): dataset creation, model generation, and export helpers.
- [src/SettingsAction.Tree.inl](E:/Coding/DevBundle/GenerateTHESISImages/source/XSCGeneDetectPlugin/src/SettingsAction.Tree.inl): tree-related logic.
- [src/SettingsAction.Serialization.inl](E:/Coding/DevBundle/GenerateTHESISImages/source/XSCGeneDetectPlugin/src/SettingsAction.Serialization.inl): serialization support.

## Build Requirements

The project expects a ManiVault development environment with:

- CMake 3.22 or newer,
- Qt 6 with `Widgets`, `WebEngineWidgets`, and `Concurrent`,
- ManiVault packages for `Core`, `PointData`, and `ClusterData`,
- the `XSCTreeData` plugin/library available at build or install time.

Relevant CMake variables:

- `ManiVault_INSTALL_DIR`: ManiVault installation root.
- `MV_CSCTD_INSTALL_DIR`: installation root for `XSCTreeData`.
- `XSCTREEDATA_LINK_LIBRARY`: optional explicit override for the tree data plugin library.

## Building

Typical CMake flow:

```powershell
cmake -S . -B build -DManiVault_INSTALL_DIR="C:\Path\To\ManiVault"
cmake --build build --config Release
```

On successful build, the plugin is installed into the ManiVault `Plugins` directory via the post-build install step defined in [CMakeLists.txt](E:/Coding/DevBundle/GenerateTHESISImages/source/XSCGeneDetectPlugin/CMakeLists.txt).

## Runtime Data Expectations

The plugin assumes:

- the selected species and hierarchy cluster datasets are children of the main points dataset,
- the embedding dataset is also a child of the main points dataset,
- point dimension names correspond to gene identifiers,
- the reference tree contains the same species names as the species cluster dataset.

If these relationships are missing or inconsistent, the plugin will refuse to compute and log diagnostic messages.

## Performance Notes

Recent optimization work focused on reducing full recomputation cost and UI overhead:

- chunked matrix reads are used instead of fetching one gene at a time,
- selected-cell statistics are aggregated in-memory after a single chunked read over the selected points,
- repeated linear lookups in selection remapping and hierarchy membership checks were replaced with hashed or linear-time helpers,
- forced waits around t-SNE stop actions were removed,
- expensive UI auto-sizing and duplicate signal connections were reduced.

Even with those changes, some operations can still be costly on very large datasets because the plugin may need to:

- rebuild large table models,
- update multiple derived ManiVault datasets,
- refresh scatterplot color/selection state,
- and serialize many tree payloads for hierarchy exploration.

## Maintenance Notes

If you extend the analysis logic, prefer:

- batched point reads over per-gene calls,
- explicit invalidation/caching boundaries,
- stable table widths over repeated `resizeColumnsToContents()` calls in hot paths,
- and avoiding repeated signal connections inside methods that run on every update.
Loading
Loading