Entering edit mode

18 months ago

Sam
•
110

When I try to run the heatmap2 for my dataset of log2 FC , I got 'x' must have at least 2 rows and 2 columns error, how I can solve this error for my dataset matrix?

Thanks

```
id log2FoldChange
mir-120a-5p -5.900679019
mir-190b-3p 2.8326859513
mir-173-5p 2.9164912341
mir-21d -2.447722216
```

Yes, as the error states, a heatmap requires at least 2 rows and 2 columns. Here, you are just trying to plot log (base 2) fold changes, which would be better represented by a simple

`plot()`

If you want to create a heatmap of your list of mirs of interest, then you have to filter your original expression data-matrix with the IDs of the mirs of interest, and then re-run the heatmap function on the sub-set of this expression matrix.

Hi Kevin, I'm new in R, could you explain a bit more about filter of mir id's?

you are plotting rownames against one column so this is not a heatmap rather just a plot of points corresponding to your miRNA id's. So if you want to plot a heatmap either you should make a matrix or dataframe in R for the ID that you are interested, pull the corresponding normalized expression values(this can be TPM, logCPM, RPKM(single end), FPKM(paired-end) for those genes for all your samples on which this log2FoldChange are estimated and then plot the heatmap.

The above will produce a matrix for x rownames (genes) across different y (samples/replicates having values that encompass your condition of interest on which differential expression analysis was performed).

This data frame can be imported into R and then you can perform your heatmap with preferrable heatmap tools in R.

Hi Sam, as vchrs implies, you first need to save your mir IDs of interest in a vector.

Then, you can subset your original data matrix with something like:

`MyMatrixOfInterestingMirs <- MyMatrix[ MyInterestingMirs, ]`

Then:

`hearmap.2(data.matrix(MyMatrixOfInterestingMirs)`

Your vector of interesting mirs will be stored in

`MyInterestingMirs`

in this example.Thanks in advance Kevin, could you also help me in command for volcano plot( log2 fold change vs. -log2 P-value)? some thing like this link : https://www.researchgate.net/figure/6680131_fig4_Volcano-plots-log2-fold-change-vs-log2-P-value-A-gene-was-identified-as

You can take my code from here for a very simple volcano plot: A: Volcano Plot from DEseq2 (scroll down a bit).

I have other more complex code that does a very good job for producing a volcano plot, but I have not yet shared it on Biostars.

I introduced the out put of deseq2 as input matrix wit this command :

but I got this error: Error in Math.factor(res$pvalue) : ‘log10’ not meaningful for factors

Try it with

`stringsAsFactors=FALSE`

inread.table, and then ensure that the pvalues are numeric withas.numeric:with removing n/a padj problem solved and I got plot but instead of miR name , each dot labeled by row number , how I can replace them with each miR name ?

Ideally your object

resshould have mirs as the rownames? Then they will automatically be used by heatmap.2 for labeling.Otherwise, you can explicitly specify labels with the

labRowandlabColparameters of heatmap.2 (in these situations, the order of the names that you use have to match the order of rows and columns in the data-matrix on which the heatmap is being generated).this is my input matrix with mirname :

No, the input matrix has to be just a matrix of expression values, with (usually) genes as rows and samples as columns. The pasted data in your above comment is the results of a differentially expression analysis, which would have been performed on your matrix of expression values.

You use the differential expression results to find statistically significant mirs/genes, and then filter your matrix of express values based on these.

I'm not sure that there's a tutorial on Biostars for heatmaps, but take a look at this one in order to get the general idea: https://www2.warwick.ac.uk/fac/sci/moac/people/students/peter_cock/r/heatmap/

I used above data to draw volcano plot , and I want to label volcano dot with miR names.

Ah, apologies! I'm involved in numerous threads/questions and forgot that we had moved onto the volcano plot. To add labels, use the line that I commented out in my code ont he page to which I linked.

If you have further issues, it may be useful to open a new question, as this question was originally about heatmaps.