blekhmanlab / biomehorizon

Plot microbiome time series in parallel
Other
24 stars 2 forks source link

Plotting error with nonsample data #14

Closed ecarr6771 closed 1 year ago

ecarr6771 commented 1 year ago

I got the following error when running horizonplot(paramList) with nonsample data, which I assume has to do with input data formatting. Is this an error that's been seen before? Could you provide insight into where to look for the cause? Error in[<-: ! Assigned dataunlist(otudata[i, 2:(ncol(otudata) - 1)]) - ...must be compatible with row subscripti. ✖ 1 row must be assigned. ✖ Assigned data has 3 rows. ℹ Row updates require a list value. Do you needlist()oras.list()? Caused by error invectbl_recycle_rhs_rows()`: ! Can't recycle input of size 3 to size 1. Backtrace:

  1. biomehorizon::horizonplot(paramList)
    1. tibble (local) <fn>(<vctrs___>)
    2. tibble:::vectbl_recycle_rhs_rows(value, length(i), i_arg, value_arg, call) Error in [<-(*tmp*, i, 2:(ncol(otudata) - 1), value = c(ST_DNA_1 = 0.481265039532485, :

✖ 1 row must be assigned. ✖ Assigned data has 3 rows. ℹ Row updates require a list value. Do you need list() or as.list()? Caused by error in vectbl_recycle_rhs_rows(): ! Can't recycle input of size 3 to size 1.`

ecarr6771 commented 1 year ago

I solved this issue by reading in the file using data.frame() around read_csv(), forcing the format to be the expected format. For example: data <- data.frame(read_csv('myHomeDirectory/my.File'))

I also needed to cast any doubles to integers using as.integer()

isaacfink21 commented 1 year ago

Thanks for posting your solution, @ecarr6771! The expected format of otudata is a data frame, so imported CSV files will need to be converted using data.frame, as you wrote here. The numeric values within the data frame must either be integers representing number of sample reads per OTU, or fractional proportions of the total sample in a given OTU. Feel free to reach out if you have any additional questions.