For each variable, It is important to understand to what NA actually relates. Does it mean that the variable was below the detection limit?; the patient never showed up for the test?; the test failed QC?
Some strategies that have been used for different types of NAs in continuous data:
- impute them as 0
- replace them with half the lowest value
- replace with the median (if univariable testing)
You can also model the data and impute the values as model predictions.
In reality, you may not have much choice but to eliminate the samples with NAs. Looking at your data, for example, what can you realistically do with those samples that are all NA across your variables? That is a situation where, perhaps, you should bite the bullet and accept that the data is too poor to use, i.e., as opposed to trying to use it.
If you are using these in regression against your WGCNA modules, for example, then an error will be thrown. If you just correlate them, then the correlation test will usually delete the samples with NA automatically - this is controlled via the use
argument passed to cor()
:
use
an optional character string giving a method for computing covariances in the presence of missing values. This must be (an abbreviation of) one of the strings "everything", "all.obs", "complete.obs", "na.or.complete", or "pairwise.complete.obs".
Kevin
Yes, Kevin, thanks for your help, I will check my data again, hoping to reach a not bad result. Thanks again!
But, dear Kevin, please forgive my carelessness firstly. It's happened to me that there are "ClinicalTraits.csv" in WGCNA tutorial, like this,ClinicalTraits.csv, and we can see many NAs in this table. Another, I have noticed that tutorial codes didn't cut or make any other treatments to these NAs. The tutorial used trait file directly, as following codes,
It looks like Nas didn't influence WGCNA analysis. What I missed? Please show me more. A big thanks!!!
The
numbers2colors()
function can tolerate NAs, but it just colours them the default 'grey':[from: https://www.rdocumentation.org/packages/WGCNA/versions/1.66/topics/numbers2colors]
Thanks for your patience~ Wish you have a great day!
Dear Dr. Blighe In the preprocessing step, I ran goodsamplegens() function by below argument for myExprdata(36*19179):
and via that process, 146 genes were removed and I got 19033 genes. after that, I ran gcg$allok and got TRUE. but after this step, I check myExprdata and again I found 71 missing values. So, I ran goodsamplegens() function by below argument for myExprdata again:
but at this time, 178 genes were removed. 22 genes more than befor try and now I have 19001 genes without any missing. I would like to have your comments about my decision. did my decision right? or should I make another decision? I appreciate if you share your comment with me.
There does not seem to be any problem with your decision.