Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two-step hybrid refactoring #34

Merged
merged 87 commits into from
May 10, 2022

Conversation

maximskorik
Copy link
Member

@maximskorik maximskorik commented Apr 20, 2022

  • added test data for two-step hybrid
  • switched most of data handling functionality to dplyr framework
  • refactored two-step hybrid into individual steps
  • extracted repeating methods in adjust.time.R and feature.align.R
  • reformated semi.sup.R and two.step.hybrid.R

Copy link
Member

@hechth hechth left a comment

Choose a reason for hiding this comment

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

Amazing work! Couple small changes to fix some possible sources of error and this can be merged!

I'll run some additional tests manually later as well and see if everything runs smoothly.

R/peak.characterize.R Show resolved Hide resolved
R/two.step.hybrid.R Outdated Show resolved Hide resolved
for (batch_id in batches_idx)
{
this.fake <- step_one_features[[batch_id]]
this.fake.medians <- distinct(this.fake, mz, rt, intensity)$intensity
Copy link
Member

Choose a reason for hiding this comment

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

Are these really the medians? If so, how do the distinct intensities form the medians?

Copy link
Member Author

Choose a reason for hiding this comment

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

At this step this.fake is a long table where intensity is the column name of median intensities. Since each feature is repeated in multiple rows (a row for a sample) and values in intensity column is the same for all samples of a given feature, distinct selects a median intensity of each unique feature.
In retrospect, calling a column that stores median intensities as intensity is confusing. Fixed that in 976e416.

Copy link
Member

Choose a reason for hiding this comment

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

cool - how comes that the distinct(...) function actually computes the median intensities? I thought that it actually selects the unique values in the list?

Copy link
Member Author

@maximskorik maximskorik May 5, 2022

Choose a reason for hiding this comment

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

It doesn't compute the medians. The medians are already computed and stored in the intensity column. distinct(...) only selects the median intensities of each unique feature.

Copy link
Member Author

Choose a reason for hiding this comment

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

Refactored this part in 99ae4f5.

R/two.step.hybrid.R Show resolved Hide resolved
Comment on lines 220 to 221
colnames(final.ftrs) <- stringr::str_remove_all(colnames(final.ftrs), ".mzml")
colnames(final.times) <- stringr::str_remove_all(colnames(final.times), ".mzml")
Copy link
Member

Choose a reason for hiding this comment

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

Is this required, to strip the file ending? If so, this should be done more robustly.

Copy link
Member Author

@maximskorik maximskorik May 4, 2022

Choose a reason for hiding this comment

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

No, it's not required. Having a file extension appended to a sample name in the table just doesn't seem pleasant or valuable.

Copy link
Member

Choose a reason for hiding this comment

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

Then this should be changed to strip any file ending since there could also be other names than only ".mzml".

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 4e89fa3.

R/two.step.hybrid.R Outdated Show resolved Hide resolved
R/two.step.hybrid.R Outdated Show resolved Hide resolved
R/two.step.hybrid.R Outdated Show resolved Hide resolved
R/two.step.hybrid.R Outdated Show resolved Hide resolved
R/two.step.hybrid.R Outdated Show resolved Hide resolved
Copy link
Member

@hechth hechth left a comment

Choose a reason for hiding this comment

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

Looks good!

Comment on lines +188 to +189
colnames(final.ftrs)[sample_cols_idx] <- tools::file_path_sans_ext(colnames(final.ftrs)[sample_cols_idx])
colnames(final.times)[sample_cols_idx] <- tools::file_path_sans_ext(colnames(final.times)[sample_cols_idx])
Copy link
Member

Choose a reason for hiding this comment

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

Nice way to exclude the file endings!

@maximskorik maximskorik merged commit 1301763 into RECETOX:master May 10, 2022
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