Пример #1
0
def renameFcsFile(Fpath):
    for file in [
            file for file in os.listdir(Fpath)
            if os.path.splitext(file)[1] == ".fcs"
    ]:
        filename = Fpath + '/' + file
        fcs = Fcs(filename)
    Fcs.panel_rename()
Пример #2
0
if __name__ == '__main__':
    ###################################################
    ####    1.Read FCS file and convert to CSV     ####
    ###################################################
    # Choose File Path
    Fpath = filedialog.askdirectory()
    os.makedirs(Fpath + "/WriteFcs/")
    csv_path = Fpath + '/WriteFcs/'

    for filename in [
            filename for filename in os.listdir(Fpath)
            if os.path.splitext(filename)[1] == ".fcs"
    ]:
        file = Fpath + '/' + filename
        fcs = Fcs(file)
        pars = fcs.pars
        new_filename = re.sub("-", "", filename)
        new_filename = re.sub("^.+?_", "", new_filename)
        # new_filename = re.sub("^.+?_", "", new_filename)
        new_file = Fpath + "/WriteFcs/" + new_filename + '.csv'
        fcs.write_to(new_file, pars, to='csv')

    path = Fpath + "/WriteFcs"
    all_df = pd.DataFrame()
    for file in os.listdir(path):
        df = pd.read_csv(path + '/' + file)
        all_df = all_df.append(df)
        print("File %s has finished." % file)
    all_df.iloc[:, :-1].to_csv(path + '/' + path.split('/')[-2] + '.csv',
                               index=False)
Пример #3
0
from FCS import Fcs
from tkinter import filedialog
import os
import re
from tkinter import Tk

# 选择路径
root = Tk()
root.withdraw()
Fpath = filedialog.askdirectory()

# 读取panel表信息
panel_file = Fpath + "/panel.xlsx"
panel_tuple = Fcs.export_panel_tuple(panel_file)
print(panel_tuple)

for filename in [
        filename for filename in os.listdir(Fpath)
        if os.path.splitext(filename)[1] == ".fcs"
]:
    file = Fpath + '/' + filename
    fcs = Fcs(file)

    pars = fcs.delete_channel(fcs.pars, 89, 115, 140, 115)
    # pars = fcs.marker_rename(fcs.pars, *panel_tuple)
    # stain_channel_index = fcs.get_stain_channels(pars)
    #
    # # 添加event_length, 191, 193, 194, 140
    # add_channel = ["Event_length", "Ir191Di", "Ir193Di", "Pt194Di", "Ce140Di"]
    # add_index = [i + 1 for i in range(0, len(pars)) if pars[i].par_short_name in add_channel]
    # stain_channel_index.extend(add_index)
Пример #4
0

if __name__ == '__main__':
    ###################################################
    ####    1.Read FCS file and convert to CSV     ####
    ###################################################
    # Choose File Path
    Fpath = filedialog.askdirectory()
    os.makedirs(Fpath+"/WriteFcs/")
    os.makedirs(Fpath+"/Output/")
    csv_path = Fpath + '/WriteFcs/'
    output_path = Fpath + '/Output/'

    # Read Panel Information
    panel_file = Fpath + "/panel.xlsx"
    panel_tuple = Fcs.export_panel_tuple(panel_file)
    print(panel_tuple)

    for filename in [filename for filename in os.listdir(Fpath) if os.path.splitext(filename)[1] == ".fcs"]:
        file = Fpath + '/' + filename
        fcs = Fcs(file)
        pars = fcs.marker_rename(fcs.pars, *panel_tuple)
        stain_channel_index = fcs.get_stain_channels(pars)

        # Add event_length, 191, 193, 194, 140
        add_channel = ["Event_length", "Ir191Di", "Ir193Di", "Pt194Di", "Ce140Di"]
        add_index = [i + 1 for i in range(0, len(pars)) if pars[i].par_short_name in add_channel]
        stain_channel_index.extend(add_index)
        pars = [pars[i] for i in range(0, len(pars)) if i + 1 in stain_channel_index]
        # Rename new file
        new_filename = re.sub("-", "", filename)
Пример #5
0
from FCS import Fcs
from tkinter import filedialog
import pandas as pd
import os
import re

if __name__ == '__main__':
    # 选择路径
    Fpath = filedialog.askdirectory()
    os.makedirs(Fpath + "/WriteFcs/")

    # 读取panel表信息
    panel_file = Fpath + "/panel.xlsx"
    panel_tuple = Fcs.export_panel_tuple(panel_file)
    print(panel_tuple)

    for filename in [
            filename for filename in os.listdir(Fpath)
            if os.path.splitext(filename)[1] == ".fcs"
    ]:
        file = Fpath + '/' + filename
        fcs = Fcs(file)

        # 重写marker-name
        pars = fcs.marker_rename(fcs.pars, *panel_tuple)
        # 导出指定通道写出
        # export_channel_tuple = ("Event_length", 115, 140, 144, 145, 148, 149, 153, 155, 158, 160, 163, 165, 170, 174, 191,
        #                         193, 194, 197, 198)
        # pars = fcs.export_channel(pars, *export_channel_tuple)
        # print(len(export_channel_tuple), len(pars))
Пример #6
0
from FCS import Fcs
from FCS import StainFcs
from FCS import Write
from tkinter import filedialog
import random
import os

# 选择路径
Fpath = filedialog.askdirectory()
for file in [
        file for file in os.listdir(Fpath)
        if os.path.splitext(file)[1] == ".fcs"
]:
    filename = Fpath + '/' + file

    fcs = Fcs(filename)

    # # 写到excel中
    # fcs.fcs2excel()

    # 染色通道
    # stain_fcs = StainFcs(filename)
    # stain_fcs.fcs2excel(folder_name="Stain_excel")

    # # 写出到fcs中
    # save_dir = fcs.file_dir + "/WriteFcs"
    # # excel文件夹不存在时创建
    # if not os.path.exists(save_dir):
    #     os.makedirs(save_dir)
    # filename = save_dir + '/' + file
    #