ethanbass/chromatographR

I can't find the "get_chrom_list" function for plot.peak_list

Closed this issue · 6 comments

In my case, I am analyzing HPLC-UV data and attempting to perform peak analysis and visualization using your excellently coded program with Waters' arw files.

I imported the Waters data using chromConverter with the following code:
path <-getwd()
folders <- list.files(path = path, pattern = "my_data")
dat <- read_chroms(folders, format_in = "waters_arw")

tpoints <- as.numeric(rownames(dat[[i]]))
matplot(x=tpoints, y=dat[[i]][,1],type='l', ylab='Abs (mAU)', xlab='Time (min)')

However, I'm not sure if this is just my problem, but when I load the basic chromatographR package, the "plot.peak_list" function does not load. So, in order to resolve this, I manually assigned the function by copying and pasting the relevant code from your source code.

Follows are my HPLC data's basic attributes.
[1] "dim" "dimnames" "instrument" "detector" "software" "batch"
[7] "operator" "run_date" "sample_name" "sample_id" "injection_volume" "time_range"
[13] "time_interval" "detector_range" "format" "parser" "class"

However, even with these adjustments, I had to manually add the value for "time.units" in the attributes, which was not included in your source code.
attributes(dat[[i]])$time.units <- "min"
names(attributes(dat[[i]]))
[1] "dim" "dimnames" "instrument" "detector" "software" "batch"
[7] "operator" "run_date" "sample_name" "sample_id" "injection_volume" "time_range"
[13] "time_interval" "detector_range" "format" "parser" "class" "time.units"

However, even after doing so, the code did not work for me because the value for lambda, which corresponds to the wavelength, was NULL for me when loading the value from your code. In my case, the lambda value that your code was looking for was set to the default value of "V2".
스크린샷 2023-05-06 09 17 39

Even when I set the lambda value to "V2", the visualization still did not work. In my opinion, the fundamental issue may be that I'm not sure where the "get_chrom_list" function is located. I believe that resolving this issue may require understanding the format of the data that is processed by this function. Can you please check on this?

Thank you 👍🏼

Hi,

Thanks for your interest in the package. It sounds like there are a few points of confusion here. The plot.peak_list function is intended for visualizing integration results from the get_peaks function which finds and integrates peaks and returns a peak_list object. Thus, plot.peak_list must be presented with a peak_list from get_peaks. It sounds like you might be trying to run it directly on your list of chromatograms, which would explain some of the problems you're having. For example, time_units is an argument to get_peaks which allows you specify the units (minutes is selected by default here because it's the most common). These time units are then added as an attribute to the peak_list which is produced by this function. The plot.peak_list is an S3 generic function, meaning that you generally access it by calling plot on a peak_list object (which, again, is produced by the get_peaks function). You shouldn't really need to do this, but you can also access the function directly as chromatographR:::plot.peak_list.

If you just want to plot the chromatograms, the correct command is plot_chroms (you can consult the vignette or the manual for more details on this discussion).

The get_chrom_list function is also internal (meaning it is not exported to the package namespace). You can access it if you want with the three colons as chromatographR:::get_chrom_list however this function isn't really intended to be called by users (and you shouldn't have to do so).

Hopefully this helps clarifies some things.
Best,
Ethan

Hello, thank you for your quick response. As you said, I obtained the following result using the get_peak function.
스크린샷 2023-05-06 23 43 06

With these results, I tried to visualize the data using the following code, but I didn't get any results. There is no attr corresponding to 'chrom_list' in the list I obtained from chromConverter.
스크린샷 2023-05-06 23 52 16
I want to know the format of the chromatograms input that corresponds to "Error in get_chrom_list(x): Chromatograms not found!" Is this different format of matrix I have?

Ethan, thank you so much. Thanks to you, it was resolved successfully. This package seems to be a really good tool for processing my data. :)

Excellent! I'm glad to hear it it's working for you now. Please feel free to open another issue if you run into any more problems.

The issue discussed here with the failure of get_chrom_list to parse subsetted lists will be resolved by 4ddca7b.