@@ -49,9 +49,14 @@ write_cdf <- function(x, path_out, sample_name, lambda = NULL, force = FALSE){
4949 stop(" Sample name must be provided." )
5050 }
5151 }
52- if (is.null(lambda ) && ncol(x ) + as.numeric(attr(x , " data_format" ) == " wide" ) > 2 ){
52+ if (is.null(attr(x ," data_format" ))){
53+ is_long <- is.null(rownames(x )) || all(rownames(x ) == seq_len(nrow(x )))
54+ attr(x , " data_format" ) <- ifelse(is_long , " long" , " wide" )
55+ }
56+ if (is.null(lambda ) && ncol(x ) > 1 && attr(x , " data_format" ) == " wide" ) {
5357 warning(" The supplied chromatogram contains more than two dimensions. Only
54- the first two dimensions will be written to the ANDI chrom file." ,
58+ the retention times and the first column of data will be written to
59+ the ANDI chrom file." ,
5560 immediate. = TRUE )
5661 }
5762 lambda <- ifelse(is.null(lambda ), 1 , lambda )
@@ -135,7 +140,9 @@ format_metadata_for_cdf <- function(x){
135140 # datetime_standard <- as.POSIXct(datetime_str, format = "%d.%m.%Y %H:%M:%S")
136141 datetime <- format(attr(x , " run_datetime" ), " %Y%m%d%H%M%S%z" )
137142 # rt_units <- x[which(x$Group=="Interval Time" & x$Property == "Units"), "Value"]
138- rt_units <- switch (tolower(attr(x , " time_unit" )),
143+ rt_units <- attr(x , " time_unit" )
144+ rt_units <- ifelse(! is.null(rt_units ), tolower(rt_units ), NA )
145+ rt_units <- switch (tolower(rt_units ),
139146 " sec" = " Seconds" , " seconds" = " Seconds" ,
140147 " min" = " Minutes" , " minutes" = " Minutes" ,
141148 " default" = " Minutes" )
0 commit comments