I have a dataframe MutationsNumberTable like this
ACC BLCA BRCA CESC HGNC
1: 1 2 6 0 OPN4
2: 2 3 1 1 KLRB1
3: 2 23 4 5 SALL2
4: 1 8 5 7 PLCB2
Run Code Online (Sandbox Code Playgroud)
The goal is to create a matrix where I have unique pairs "gene-cancer type" where a number in a table is greater than a threshold (let's say, 5):
Desired output:
HGNC Cancer
1: OPN4 CESC
2: SALL2 BRCA
3: SALL2 CESC
4: PLCB2 BLCA …Run Code Online (Sandbox Code Playgroud) 我有一些列表中的所有对组合:
a = [1,2,3,4,5,6]
pairs = [pair for pair in itertools.combinations(a,2)]
print pairs
>>>[(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)]
Run Code Online (Sandbox Code Playgroud)
如果我只知道它的索引,我如何知道我到底在使用哪个对?也许有一些公式?问题是我的列表太大了,我无法记住所有对。我只需要一些可以通过索引识别的特定对。
有什么建议么?
谢谢!
我想生成类似于10, 7, 4, 1
seq函数无法做到这一点(开始大于停止)。什么函数可以做到这一点?我不喜欢循环我的序列(这将非常耗时,因为我需要像这样处理大量向量)。
> seq(10, 0, by=3)
Run Code Online (Sandbox Code Playgroud)
seq.default(10, 0, by = 3) 中的错误:“by”参数中的符号错误