Question: heatmap for a predetermined order of rows
0
gravatar for kanwarjag
4.2 years ago by
kanwarjag1.0k
United States
kanwarjag1.0k wrote:

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

 

Thanks

ordered matrix • 3.5k views
ADD COMMENTlink modified 4.2 years ago by dally190 • written 4.2 years ago by kanwarjag1.0k
0
gravatar for Jean-Karim Heriche
4.2 years ago by
EMBL Heidelberg, Germany
Jean-Karim Heriche21k wrote:

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.

ADD COMMENTlink modified 3 months ago by RamRS26k • written 4.2 years ago by Jean-Karim Heriche21k

What is have is I ran the clustering and have

ClusterOrder <- row.names(dat[hv1$rowInd,])
head(ClusterOrder)
write.table(ClusterOrder,file="File1.txt",sep="\t")

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

ADD REPLYlink modified 3 months ago by RamRS26k • written 4.2 years ago by kanwarjag1.0k

Use the match() function to reorder you second data set based on ClusterOrder. Something like:

data2[match(ClusterOrder,row.names(data2)),]
ADD REPLYlink modified 3 months ago by RamRS26k • written 4.2 years ago by Jean-Karim Heriche21k
0
gravatar for dally
4.2 years ago by
dally190
United States
dally190 wrote:

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 COMMENTlink modified 3 months ago by RamRS26k • written 4.2 years ago by dally190
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1774 users visited in the last hour