I generated a heat map where I have order of rows via which these are arranged. I want to use this order to plot another set of control samples to show side by side pattern. What should be the best way to do this pattern. Perhaps we may be able to do it in R or any other tool? I have only 500 rows and 3 columns
Simply reorder the rows of your second matrix to match the first one, then use for example R's heatmap() function setting Rowv=FALSE to prevent it from automatically reordering the rows, alternatively, you could set Rowv to a vector defining the order.
Do you have a "Gene" name or similar column that are identical between both data sets? If so then the merge() function in R could do this fairly easily.
Something like this should work fairly well (ignore the .cdt file extensions, this will work for most tab delimited data sets).
# Set your working directory.
setwd("~/workspace/GenomicsData/analysis/visualization/homerheatmaps/")
# Read in your files (cdt's are tab-delimited). File1 should be your sorted cdt file.
# File2 should be the cdt file you want to sort.
file1 <- read.delim("groseqheatmap_sorted.cdt")
file2 <- read.delim("hexim_heatmap.cdt")
# Merge the files together into a seperate file called file3 for easy write-out.
# Here we are sorting by gene, but any column name is appopriate (as well as number).
file3 <- merge(file1["Gene"], file2, by="Gene", sort=FALSE)
# Write out file3 for easy altering in text editor.
# file = "whatever_you_want_to_name_your_output_file"
write.table(x = file3, file = "hexim_sortedtogroseq.cdt", sep = "\t", quote = FALSE, row.names = FALSE)
ADD COMMENT
• link
updated 5.0 years ago by
Ram
44k
•
written 8.9 years ago by
dally
▴
210
What is have is I ran the clustering and have
Now I want to use File 1 order to sort the second file (File2) both files have unique matching probe id
I dont want to include my control data along with clustering as it affect ordering. I did not clarify clearly in the first instance
Use the
match()
function to reorder you second data set based on ClusterOrder. Something like: