首页 \ 问答 \ 如何在R中的heatmap.2中为一组标签或分支着色(How to color a group of labels or branches in heatmap.2 in R)

如何在R中的heatmap.2中为一组标签或分支着色(How to color a group of labels or branches in heatmap.2 in R)

通过使用?heatmap.2的数据:

data(mtcars)
x<-scale(mtcars)


set.seed(123)
tf<-sample(rownames(x), 5)
tf

[1] "Merc 280"         "Pontiac Firebird" "Merc 450SL"  
 "Fiat X1-9"        "Porsche 914-2" 

heatmap.2(x)

我想要的是用红色标记tf (右侧)的行名称或用红色标记这些名称的分支(在左侧)(或者两者都用红色标记更大)。 我挖了一下,找不到解决方案。 是否有人使用上述样本?


By using the data from ?heatmap.2:

data(mtcars)
x<-scale(mtcars)


set.seed(123)
tf<-sample(rownames(x), 5)
tf

[1] "Merc 280"         "Pontiac Firebird" "Merc 450SL"  
 "Fiat X1-9"        "Porsche 914-2" 

heatmap.2(x)

what I wanted is to color row names in tf (on the right) in red or the branches of these names (on the left) in red color (or both in red will be greater). I dug around and can't find the solutions. Does anybody have suggestions using the above sample?


原文:https://stackoverflow.com/questions/32573733
更新时间:2023-10-03 14:10

最满意答案

Q1:不会。操作系统会知道文件的大小,并且seekg()将使用这些知识 - 无论文件长度是1,100还是10000000000字节,它都需要几乎相同的时间。

Q2:不,它只是设置当前的“获取指针”,即在Windows或Linux系统中转换为“SetFilePos”或“lseek”。 几乎所有其他操作系统都有类似的概念。


Q1: No. The OS will know the size of the file, and seekg() will use that knowledge - it takes almost identical time whether the file is 1, 100 or 10000000000 bytes long.

Q2: No. It just sets the current "get pointer", which translates to "SetFilePos" or "lseek" in a Windows or Linux system. Nearly all other OS' have similar concepts.

相关问答

更多
  • find
  • 在实践中,语言实现依赖于操作系统来处理(这反过来又依赖于文件系统)。 例如,POSIX提供lseek系统调用。 因此,他们无法保证复杂性; 它们依赖于OS /硬件实现。 In practice, language implementations rely on the OS to deal with this (which in turn relies on the filesystem). For example, POSIX provides the lseek syscall. Thus they c ...
  • 问题是你写了字符串 "spam\neggs\n" 最初是一个ofstream ,没有在open (或初始化器)上设置std::ios::binary标志。 这会导致运行时转换为“本机文本格式”,即将每个\n转换为输出上的\r\n (就像在Windows操作系统上一样)。 因此,在编写之后,文件的内容实际上是: "spam\r\neggs\r\n" (即12个字符)。 那是由...返回的 int length = is.tellg(); 但是,当你试图read 12个字符时 "spam\neggs\n" ...
  • Q1:不会。操作系统会知道文件的大小,并且seekg()将使用这些知识 - 无论文件长度是1,100还是10000000000字节,它都需要几乎相同的时间。 Q2:不,它只是设置当前的“获取指针”,即在Windows或Linux系统中转换为“SetFilePos”或“lseek”。 几乎所有其他操作系统都有类似的概念。 Q1: No. The OS will know the size of the file, and seekg() will use that knowledge - it takes a ...
  • 最后一次输入操作会导致设置失败位。 如果在设置此位时调用tellg ,它也会失败。 在调用tellg()之前,您需要调用tellg() 。 txtFile.clear(); // clear fail bits txtFile.seekg(0,ios::beg); The last input operation causes the fail bit to be set. If you call tellg while this bit is set it too will fail. You need ...
  • 你可以在给定的位置之前看到kg,所以pos被签名。 尝试使用大小为0x7fffffff和0x80ffffff的文件,看看后者是否触发问题,这是我的猜测。 You can seekg before a given position, so pos is signed. Try it with files of size 0x7fffffff and 0x80ffffff and see if the latter triggers the problem, that's my guess.
  • 您需要在再次阅读之前清除流上的错误状态: ifile.clear(); 否则,第一次遇到EOF时,流进入错误状态,所有后续读取都将失败。 请注意,如果您这样做并且您的文件只包含1(或0)行,那么您当前形式的代码将永远循环。 You need to clear the error state on your stream before reading again: ifile.clear(); Otherwise, the first time it encounters EOF, the stream ...
  • 找到了我的问题的解决方案。 代码中没有任何问题,我在应用程序中添加了一些代码,并且没有初始化我的一些变量,因此影响了入口点和数据位置。 Found the solution to my problem. There wasn't any problem in the code, I had added some more code to the app and hadn't initialised some of my variables thus affecting the entry points an ...
  • fseek()的Open Group规范(可能用于实现fstream::seekg )需要允许文件位置超出当前文件结尾: fseek()函数应允许将文件位置指示符设置为超出文件中现有数据的末尾。 如果此时稍后写入数据,则后续读取间隙中的数据应返回值为0的字节,直到数据实际写入间隙。 http://pubs.opengroup.org/onlinepubs/009696699/functions/fseek.html The Open Group specification for fseek() (like ...
  • 好的,我们走了: 编号tellg()将产生有用的位置对象,以回到您所处的位置。 返回的类型是std::streampos ,它是std::fpos 。 但是, std::fpos转换为std::streamoff ,这是一个整数。 基本上, std::streampos转换为从第一个位置到当前位置的字符数。 寻找相对于std::ios_base::beg 0字符清楚地将位置设置为文件的开头。 你的意思是使用std::ios_base::cur吗 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)