Skip to content

Conversation

@robinschmid
Copy link
Member

No description provided.

totalItems = featureLists.stream().mapToInt(FeatureList::getNumberOfRows).sum();
// Get parameter values for easier use
outFile = parameters.getValue(FragmentsAnalysisParameters.outFile);
// TODO
Copy link
Member

@Adafede Adafede Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done now

@Adafede
Copy link
Member

Adafede commented Jul 18, 2024

MGF export is actually not fixed, was just random luck.

@robinschmid
Copy link
Member Author

robinschmid commented Jul 24, 2024

Use records for dataclasses
image

image


public record GroupedSignalScans(io.github.mzmine.datamodel.features.FeatureListRow row,
java.util.List<io.github.mzmine.datamodel.Scan> ms1Scans,
java.util.List<io.github.mzmine.datamodel.Scan> ms2Scans) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you should see an option for replace qith qualified import or similar to just import java.util.List instead of writing the whole class path

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see ef3e342

public @NotNull Task createTask(final @NotNull MZmineProject project,
final @NotNull ParameterSet parameters, final @NotNull Instant moduleCallDate,
final @Nullable MemoryMapStorage storage, final @NotNull FeatureList featureList) {
return new io.github.mzmine.modules.dataprocessing.process_signalsanalysis.SignalsAnalysisTask(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here should import io.github.mzmine.modules.dataprocessing.process_signalsanalysis.SignalsAnalysisTask

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see aa6aca6

private final double ms1Intensity;
private final double commonIntensity;

private SignalsResults(int commonCount, int ms1Count, int ms2Count, int precursorsCount,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use record for this instead of class. record is Java equivalent of pythons @DataClass.
It comes with default constructor and immutibility.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already implemented in ed24b67

* @return A set of unique dataPoints.
*/
private Set<DataPoint> collectUniqueSignalsFromScans(List<Scan> scans, MZTolerance tolerance) {
Set<DataPoint> uniqueSignals = new HashSet<>();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the unique signals here are not really unique because you still got each signal for each scan duplicated? Is that intended?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, addressed it using your version in 93b4fc2

@Adafede
Copy link
Member

Adafede commented Jul 24, 2024

@robinschmid Thank you for all the very much appreciated guidance!

I tried to address your comments and added back (and renamed for clarity) the number of fragmented MS1 signals, as I believe this might also be a good metric.

The MS1 matched signals and MS2 matched signals columns (https://github.com/mzmine/mzmine/pull/1964/files#diff-5ce889ab2e58e67207309de324fdbd144290462e8306593093353a4a6c2606fbR248-R251) seem redundant but maybe you wanted to let them for sanity check?

@Adafede Adafede force-pushed the fragments_analysis branch from f1a1768 to 08dade1 Compare July 29, 2024 10:38
@robinschmid
Copy link
Member Author

image

@robinschmid robinschmid marked this pull request as ready for review August 2, 2024 10:08
@Adafede
Copy link
Member

Adafede commented Aug 2, 2024

🚀

Copy link
Member

@SteffenHeu SteffenHeu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey adriano,

this looks like a great tool, good work! I have some questions regarding the implementation though, because i sometimes dont really get whats happening. can you clarify them please?

import org.jetbrains.annotations.NotNull;

/**
* Flag if signal is most likely in source fragment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where/how is this flag determined? can you add a link to the method?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 95df679

import io.github.mzmine.datamodel.features.types.numbers.abstr.PercentType;
import org.jetbrains.annotations.NotNull;

public class Ms1SharedIntensityPercentType extends PercentType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please describe shortly here what this type does. Also we will need a documentation page. Please add a description to all the types so we know if and for what we can reuse them in the future

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 95df679

import org.jetbrains.annotations.NotNull;

/**
* All scans of all precursors in mz and RT range
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Across all files or in a single file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one's associated to the row? Isn't this decided previously already?

* How many of the MS1 signals in the corresponding MS1 scans were fragmented? Measured by their
* intensity
*/
public class PrecursorIonsIntensityPercentType extends PercentType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if i look at a single scan and determine how much of all ions in this scan are associated with an ms2 in a reasonable rt range?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 95df679

import io.github.mzmine.datamodel.features.types.numbers.abstr.IntegerType;
import org.jetbrains.annotations.NotNull;

public class SharedSignalsType extends IntegerType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In an MS2? Shared between what`?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 95df679

ms2Scans);
Set<Double> precursorMzSet = ms1SignalMatchesMs2Precursors.stream().map(UniqueSignal::mz)
.collect(Collectors.toSet());
List<UniqueSignal> ms1FragmentedSignalMatchesMs2 = ms1Signals.stream()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step is based on the assumption that the unique ms1Signals are from the same file as the precursorMzSet. Otherwise the mzs may be within the tolerance, but not exactly the same. Do you need the precursorMzSet? Isnt it better to maybe filter down the ms1Signals map to a smaller range map of the unique precursors?

What is going on here exactly? Are you looking for signals that were fragmented and where the precursor mz is still in one of the ms2s?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit down below it sounds like this should be all the ms1 signals that were also seen in any of the ms2 scans. Then the first filter step with the precursorMzSet prevents that from happening, or?

// you could build a RangeMap<Double, UniqueSignal> of all rows with fragment spectra (precursor m/z)
// before looping over all rows and pass it into this method
// Or maybe we need to accumulate all MS2 fragment signals over all scans?
List<UniqueSignal> ms1SignalMatchesMs2Precursors = filterUniquePrecursors(ms1SignalMap,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming proposal: uniqueMs1SignalWithMs2Scans? sounds more understable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 033775a

double ms1SignalsMatchedPercent = signalsMatched / (double) ms1SignalsTotal;

// for all precursor ions
int ms2SignalsAllPrecursors = mapToList(ms2SignalMap).size();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesnt RangeMap have a size method?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly does not seem so 😞


// only for this precursor ion
List<UniqueSignal> ms2Signals = mapToList(ms2SignalMap).stream()
.filter(signal -> originatesFromPrecursorIon(signal, tolerance, precursorMz)).toList();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont really get it here, what is this doing? It's going through every ms2 signal, then going to the ms2 scans of these signals, getting the precursor mz and then checking if the scan's precursor mz matches the precursorMz?
Then the easier way is to just check the precursor mz of the ms2 scans themselves or? In the current way each scan is checked as much times as it has ms2 signals or not?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

originatesFromPrecursorIon sounds more like "does this signal appear in the ms2 of this precursor" to me but then you would need to compare the signals in the ms2s of that precursor to the signals in the ms2Signal map. Or is that happening here and i dont get it? :D sorry

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed now (see 46b9991)

* @param precursorMz
* @return The results of the signal count.
*/
private SignalsAnalysisResult countUniqueSignalsBetweenMs1AndMs2(List<Scan> ms1Scans,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method is doing a lot of things and is quite hard to understand. is it possible to divide it into smaller chunks?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to make it more understandable: c99fd1d

@Adafede Adafede force-pushed the fragments_analysis branch from 351453a to cdda0a9 Compare October 8, 2024 13:26
@Adafede Adafede force-pushed the fragments_analysis branch 4 times, most recently from 554b385 to e822060 Compare November 8, 2024 07:26
Adafede and others added 12 commits November 8, 2024 08:32
# Conflicts:
#	mzmine-community/src/main/java/io/github/mzmine/datamodel/data_access/EfficientDataAccess.java
#	mzmine-community/src/main/java/io/github/mzmine/gui/mainwindow/MainMenu.fxml
#	mzmine-community/src/main/java/io/github/mzmine/modules/batchmode/BatchModeModulesList.java
#	mzmine-community/src/main/java/io/github/mzmine/modules/dataprocessing/filter_isotopefinder/IsotopeFinderTask.java
#	mzmine-community/src/main/java/io/github/mzmine/util/scans/ScanUtils.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants