Entering edit mode
3.4 years ago
cthangav
▴
110
Hello, I have been trying to get this MOFA tutorial to work with my data set, but keep getting this error when the model is trained.
Error in `$<-.data.frame`(`*tmp*`, "feature", value = c("chr1:3514872-3515102", :
replacement has 131600 rows, data has 0
My code is very similar to the tutorial:
data <- fread("C:/Users/cathe/Desktop/NordenLab/Project/06172021 MEFISTO/Works/LongDataframe10Samples.txt")
data = data.frame(data)
#create MOFA Object
MOFAobject <- create_mofa(data)
MOFAobject
plot_data_overview(MOFAobject)
#Options
data_opts <- get_default_data_options(MOFAobject)
model_opts <- get_default_model_options(MOFAobject)
train_opts <- get_default_training_options(MOFAobject)
#Build Train MOFA Object
MOFAobject <- prepare_mofa(
object = MOFAobject,
data_options = data_opts,
model_options = model_opts,
training_options = train_opts
)
#Run MOFA
outfile = file.path(getwd(),"model.hdf5")
MOFAobject.trained <- run_mofa(MOFAobject, outfile)
So there is something wrong with my data.frame, which is formatted like this:
> data
sample feature value view
1 MEF 0610005C13Rik 3.465742e-01 RNA
2 MEF 0610007P14Rik 4.508857e+01 RNA
3 MEF 0610009B22Rik 3.927700e+01 RNA
4 MEF 0610009L18Rik 3.487817e+00 RNA
5 MEF 0610009O20Rik 3.056666e+01 RNA
...
779921 iPSC5 chrY:90824242-90824507 31 ATAC
779922 iPSC5 chrY:90825138-90825545 38 ATAC
779923 iPSC5 chrY:90835583-90835832 19 ATAC
779924 iPSC5 chrY:90841589-90841857 31 ATAC
779925 iPSC5 chrY:90843869-90844126 16 ATAC
Any thoughts on how to resolve this error? Similar Error and Solution : https://stackoverflow.com/questions/64164612/error-in-data-framex-name-value-replacement-has-1-row-data-has-0
That is not just a
data.frame
, it's still adata.table
-print(data.frame_obj)
does not print the last few rows.. Maybe try usingsetDF(data)
.thank you for the comment. I copy/pasted the last few rows by using the tail function. Sorry for the confusion, it didn't show up exactly like that when I printed it.
I ran the following code based on your recommendation to use setDF(), but still getting the same error.
In that case, the problem is not what I thought it was. Maybe someone else has a more productive lead. Sorry I couldn't help more.
EDIT: I meant to say "not what I thought it was", not "now what I thought it was" - changes the whole meaning, sorry about that!
Could you provide example data as
dput(head(data))
?I am guessing you are getting the error after this step:
MOFAobject <- create_mofa(data)
, I'd address the developers at GitHub (MOFA2/issues), most likely the input dataframe is not in the right format.Error is easily reproducible as:
So that error might be happening in the create_mofa() step?
Here is the dput(head(data))
Here is their example in the tutorial, which does not cause the same error: