Is there a way to convert the density()
function in R to a data-frame?
So lets give the easiest example possible. Say my variable contains the numbers 2, 4, 4, 6
I want to be able to convert this numbers to a density data.frame.
Value Density
2 .25
4 .50
6 .25
I know your probably thinking why? but I have a good reason I promise. Thanks for the help!
I'm working on a ChIP-seq project where I'm looking at the MACS2 called peak lengths of differentially expressed H3K4me3 marked genes found in the presence of an RNAi knockdown of two methyl transferase enzymes. I am plotting the histogram of peak length of each respective RNAi knockdown affected gene to see if the methyl transferase enzymes are responding to a pattern in the chromatin mark (gene length). I want to overlay a density plot of the average peak length of all genes to show how the RNAi affected genes deviate from the overall mean but in ggplot this is not easy. So my data-wrangling approach is to plot a line overlaying the histograms with the respective density parameters (in which I need the density coordinates).
The reason I didn't post this at the top was because it's complicated and I didn't think it was too relative to answering my question. I realize my example wasn't exactly what I asked because I didn't know how to explain it on the face of a forum so I thought I'd give the "easiest example possible". However, thank you for perfectly answering the question that I meant to ask. I'm new to biostars so I was under the impression that biostars was a forum where bioinformaticians could ask any coding questions they had but maybe my question was better suited for Stack Overflow. I'll be more descriptive in the future.
Lastly, in the future in a professional forum such as this, it might be good to respond in a constructive criticism sort of way rather than passive aggressively.
Not being passive-aggressive mate, just trying to help people better articulate their questions.
You're correct: if it's a "general coding question", Stack Overflow is good; if it's posted here, we like to see the application to the bioinformatics problem.