我目前正在编写“正在做”的程序,并绘制DNA样本的相位分析,并且出现了一些问题:Output plot HERE!右侧的图像来自MATLAB并且是它应该如何看起来的例子。左边的图像是从我的程序输出的。正如你所看到的蓝色图形看起来是正确的,但它是在不同的角度。我检查过代码,它和我的程序的MATLAB版本基本相同。无论如何,我会把它放在这里,也许有一个我不知道的错误。但如果不是这样,是否有一种“转向/降低”的方式将图形展示到正确的位置?如何在python中以某个角度“降低”图形
Python代码在这里:
def listIni(size, const=0):
return [const] * size
seq = SeqIO.read("C:/ec.fasta", "fasta")
seqString = seq.format("fasta")
seq = seqString[72:]
seqLen = len(seq)
phase = listIni(seqLen)
A = complex(1, 1)
T = complex(1, -1)
C = complex(-1, -1)
G = complex(-1, 1)
RNL = range(0, seqLen)
ntLoc = np.asarray(RNL)
for i in RNL:
if seq[i] == "A":
phase[i] = np.angle(A)
elif seq[i] == "T":
phase[i] = np.angle(T)
elif seq[i] == "C":
phase[i] = np.angle(C)
else:
phase[i] = np.angle(G)
arrPh = np.asarray(phase)
unwrapedPh = np.unwrap(arrPh)
cumulatedPh = np.cumsum(arrPh)
plt.plot(ntLoc, unwrapedPh, label='uPhase', color='red')
plt.plot(ntLoc, cumulatedPh, label='cPhase', color='blue')
plt.xlabel("Relative nt location")
plt.ylabel("Angle")
plt.show()