Hey guys, first time posting because I got really really stumped last night for the first time in R. Hope this is the right forum for a question relating to code. If not, by all means remove. Thanks.
I have this data frame that is 3 columns x 36000 rows. Early in the code I transposed the data frame so the frame I am trying to use when this hiccup occurs somehow becomes 36000c x 2r.
I would expect two rows from that, as in this super simple example:
> DF <- data.frame(A = LETTERS[1:4], B = 1:4, C = 2:5)
> DF
A B C
1 A 1 2
2 B 2 3
3 C 3 4
4 D 4 5
> t(DF[, -1])
[,1] [,2] [,3] [,4]
B 1 2 3 4
C 2 3 4 5
Ah, I see. Removing the first column to transpose the data and add the column back as row headings is what made the number of rows go down to 2 when I expected it would stay as 3.
I still can't seem to figure out why I've created a group for each row resulting in 2 groups, and the output of the matrix dimensions shows the number of rows as 2, yet the error still occurs.
dim(BOP1_flg22_vs_WT_flg22_rnaseq)
[1] 2 32833
and
BOP1_flg22_vs_WT_flg22_rnaseq_group
group
WT.flg22.__pd__2..BAM. WT_flg22
bop1.6D.flg22.__pd__2..BAM. BOP1_flg22
I had it that way originally, but when it is like that the function doesn't read the DF at all. Instead it results in an error as follows:
BOP1_flg22_vs_WT_flg22_rnaseq_results <- dnapath(BOP1_flg22_vs_WT_flg22_rnaseq, pathway_list = NULL, groups = BOP1_flg22_vs_WT_flg22_rnaseq_group, network_inference = run_pcor, seed = 1)
Error in matrix(0, nrow = p, ncol = p) : non-numeric matrix extent
In addition: Warning message:
In dnapath(BOP1_flg22_vs_WT_flg22_rnaseq, pathway_list = NULL, groups = BOP1_flg22_vs_WT_flg22_rnaseq_group, :
Only 0 permutations are possible with the given sample size. Setting 'n_perm' to this value.
The groups argument should be a vector. Quoting from the documentation:
" groups is a vector of length equal to the number of rows in x , and it should contain two unique elements (the two group names)"
My guess is that passing groups as a data frame is causing a problem.
Hmm. I messed around with that just now and it didn't seem to result in any fix. I have practically followed the documentation code identically. I think it has something to do with the number of rows in the data frame. Every sort of display and dimensions of the frame shows 2 rows present as I demonstrated, yet the error claims nrow(x) = 1. That unfortunately seems to be the issue, the number of groups is right were I want it (2).
I think I might have to scrap it and start fresh since there really appears to be nothing wrong.
The idea is that dnapath() accepts matrices as well as data frames and that I do not think row names matter. I could be wrong, I have never used this function.