hadexversum / HaDeX

Analysis and Visualisation of Hydrogen/Deuterium Exchange Mass Spectrometry Data
http://mslab-ibb.pl/shiny/HaDeX/
8 stars 2 forks source link

Thank you and comment #47

Open alonsoizzat opened 3 years ago

alonsoizzat commented 3 years ago

First at all, thank you very much for your package. It has been really cool to see an R package for HDX data. I have just started using it, so I would like to thank you all.

I have one or two comments.

Disclaimer: I am not programmer. I just know some R and do HDX and was just using your software to plot some HDX data, since I like it, I wanted to share these ideas with you (I guess you probably already thought of it, but just in case)

In order to process directly the kinetic for all the peptides, I wrote this:

dat <- read_hdx(system.file(package = "HaDeX", "HaDeX/data/KD_180110_CD160_HVEM.csv"))

check the states and proteins in the experiment. This is only for me, to list the diff states and proteins

States <- unique(dat[["State"]]) Proteins <- unique(dat[["Protein"]]) Exposure <- unique(dat[["Exposure"]])

kin_state <- function(state, protein, time_in, time_out, start, end, sequence, data) { #this function calculates the kin for a list of peptides

peptide_state <- data %>% group_by(Sequence) %>% filter(Sequence == sequence) %>% group_by(State) %>% summarise() %>% as_vector()

if (!state %in% peptide_state) { #this filters out the peptides that are not present in the state indicated print(peptide_state) print(paste(as.character(sequence), " does not belong to", as.character(state))) kin <- NA } else { kin <- calculate_kinetics(data, #calculates kin for all the peptides for a given state in the table protein = protein, state = state, sequence = sequence, start = start, end = end, time_in = time_in, time_out = time_out)

}

return(kin)

}

so that then you can have a tidy df as follows:

kin_data <- dat %>% filter(!Sequence == "") %>% mutate("Seq_peptide" = Sequence) %>% group_by(Sequence) %>% nest() %>% mutate("kin_State1" = map(.x = data, .f = ~kin_state(state = States[1], protein = Proteins[1], time_in = 0, time_out = 1500, start = .x$Start[1], end = .x$End[1], sequence = .x$Seq_peptide[1], data = dat)), "kin_State2" = map(.x = data, .f = ~kin_state(state = States[2], protein = Proteins[1], time_in = 0, time_out = 1500, start = .x$Start[1], end = .x$End[1], sequence = .x$Seq_peptide[1], data = dat)) )

and now, this is the main reason why I wrote. Regarding plot_kinetics, I think that it would be a good idea to have color/fill = State as well (I did it in my PC), but I think it would be useful to have it out of the box, so that you can easily do things like:

bind_rows(kin_data$kin_State1[1:8], kin_data$kin_State2[1:8]) %>% plot_kinetics_State(theoretical = FALSE, relative = FALSE) + facet_grid( ~ Sequence)

210311_example_kin_state

and then you have in one plot many peptides in panels with same color for easy comparison.

Thank you very much again.

Best, Alonso

werpuc commented 3 years ago

Dear Alonzo,

Thank you very much for contacting us. We are delighted to see that you enjoy our tool! That's what we hoped for :)

Currently, we are working on the new release of the HaDeX package. Apart from adding new features, we want to make sure that the package's functions are easy to use and helpful for various purposes. We designed most of the functions as the backend of the web-server, and now we want to focus on the usage of the functions apart from the application. I will keep your suggestions in mind, and I'll be happy to implement them.

Moreover, we are in the process of refactoring the code. I'm making sure that the names are consistent etc. If you are interested in changes, feel free to explore our dev branch: https://github.com/hadexversum/HaDeX/tree/dev_1.5.

Thank you for your suggestions. Feedback from HDX-MS practitioners is precious for us. If you have more comments on how to improve the package, I'll be happy to take them.

Best, Weronika